I have a properties file I'm using for GIS software and currently you have a feature like road, then properties under it like so:
{
"road": {
"colour": "rgb(0,0,0)"
},
"railway": {
"colour": "rgb(100,100,100)"
}
}
Now I need to group these into categories, for example Transportation. The first thing I thought of was:
{
"transportation":
{
"road": {
"colour": "rgb(0,0,0)"
},
"railway": {
"colour": "rgb(100,100,100)"
}
}
}
This makes things awkward when I want to access "road"
(for example), because now I need to know it is under "transportation"
(mind you I could always write a helper function to eliminate this). Further, "road"
could be under multiple groups, perhaps "transportation"
and "public works"
, now I would need to duplicate the properties in both instances.
Would I be wiser to use the following format, or is there a better way to do this?
{
"road": {
"colour": "rgb(0,0,0)",
"group": ["transportation"]
},
"railway": {
"colour": "rgb(100,100,100)",
"group": ["transportation"]
}
}
This is my first time using Code Review, I look forward to the feedback =). Cheers.