I have a JSON like so:
{
"parent": {
"type": "Object",
"value": {
"childName": { "type": "String", "value": "A string" }
}
}
}
Pretty much, the pattern is parent has type and value, but I want the value of parent to be value
{
"parent": {
"childName": "A string"
}
}
How can I set the parent's value to be the child named value recursively in JavaScript?
The main issue I am having is doing this recursively for a very large file.
Examples:
The start value of Level is `{ "type": "string", "value": "A string" }
I want to make the value of Level become "A String", making the end value of Level become "A String"
The start value of parentObject is { "type": "Object", "value": { "anotherObject": { "type": "string", "value": "Another string" }, "secondObject": { "type": "string", "value": "second string" } } }
I want to make the value of parentObject become { "anotherObject": { "type": "string", "value": "Another string" }, "secondObject": { "type": "string", "value": "second string" } }
And the value of anotherObject become "Another string"
Making the final result
{"parentObject": { "anotherObject": "Another string" }, { "secondObject": "second string" }}