I have many strings in the custom setting with and without dot-separated field names. For example:
- id
- name
- owner.name
- owner.id
- project.key
- project.owner.name
- project.owner.id
- document.owner.parentPerson.name
I want to dynamically create JSON string with all these fields. My expected result is:
{
"id":"some value",
"name":"some value",
"owner":{
"name":"some value",
"id":"some value"
},
"project":{
"key":"some value",
"owner":{
"name":"some value",
"id":"some value"
}
},
"document":{
"owner":{
"parentPerson":{
"name":"some value"
}
}
}
}
How can I do this? Thanks!
Best Answer
This (cursorily tested) code is the sort of thing I would write: