I retrieve the following array of string values
[
"Module1.resource1.create",
"Module1.resource1.read",
"Module1.resource1.update",
"Module1.resource1.delete",
...
"Module1.resourceN.create",
"Module1.resourceN.read",
"Module1.resourceN.update",
]
I would like to change them to json format like this
{"privileges": {
"Module1": {
"resource1": {
"create": true,
"read": true,
"update": true,
"delete": true,
},
...
"resourceN": {
"create": true,
"read": true,
"update": true,
}
}
}
}
All I can think of is run a loop for each string, use split(".") and then somehow change it to json object. the problem I'm having is that the json is not a simple key: value, it's more of a key: object: object: object: value if that makes sense ...
I would appreciate the nudge in the right direction.
cheers
loop and splitis the way to gokey: value. but not sure how to dokey: object: object: key: valueif you know what I mean ...