Starting off with react-jsonschema-form, I've encountered the need for input in a specific format. Unfortunately, dealing with nested JSON data has proven to be challenging when trying to recursively transform it into the required format.
The initial JSON structure is as follows:
{
"Coordinates": {
"X-Coordinate": 47,
"Y-Coordinate": -122
},
"Coordination Type": {
"Cartesion Mode": false,
"Starting Range": {
"Start": 8000,
"End": 9000
}
},
"Map": {
"Offline Map": false,
"URL": "http://localhost:9000"
}
}
Here is the desired recursive transformation of the JSON data:
{
"Coordinates": {
"type": "object",
"title": "Coordinates",
"properties": {
"X-Coordinate": {
"type": "number",
"title": "X-Coordinate",
"default": 47
},
"Y-Coordinate": {
"type": "number",
"title": "Y-Coordinate",
"default": -122
}
}
},
"Coordination Type": {
"type": "object",
"title": "Coordination Type",
"properties": {
"Cartesion Mode": {
"type": "boolean",
"title": "Cartesion Mode",
"default": false
},
"Starting Range": {
"type": "object",
"title": "Starting Range",
"properties": {
"Start": {
"type": "number",
"title": "Start",
"default": 8000
},
"End": {
"type": "number",
"title": "End",
"default": 9000
}
}
}
}
},
"Map": {
"type": "object",
"title": "Map",
"properties": {
"Offline Map": {
"type": "boolean",
"title": "Offline Map",
"default": false
},
"URL": {
"type": "string",
"title": "URL",
"default": "http://localhost:9000"
}
}
}
}
Even though an iterative approach was initially successful, it lacks scalability. Hence, I've been struggling for hours to develop a recursive method for this transformation.
I would greatly appreciate guidance on implementing a recursive JavaScript function to adapt the given JSON data to the specified format.