I am having trouble finding a way to iterate through this JSON file. The JSON is acquired after calling an API.
I would like to use this JSON for mapping and create components from it.
Problem: How do I navigate through nested JSON and map it?
JSON Format
The JSON format that i received is just as below. I cannot change the file as it is called from an API.
{"animals":{
"dogs":{
"name": "rex", (required)
"breed": "yorkshire"}
"cats":{
"name": "tom", (required)
"breed": "sphinx"}
}
}
Goal
Since mapping can be done in an array of objects, the ideal case would be [{dogs},{cats}].
var json = *serializableJSONFormat*
json.map((item)=>{
<MenuItem value={item.name}>{item.name}</MenuItem>
})
itemin this case?