I am currently fetching a json Object from the following sample URL: https://demo0046512.mockable.io/stream/anycontent
My purpose is to iterate trough each array ("zone") and make a switch-case which will call different methods depending on the type fields
I tried looking at this other similar case Iterating over JSON in React but I am still struggling with iterating trough the json Object correctly, what am I not doing properly?
Here's the iteration code:
interpretJson(jsonObj){
if(jsonObj){
var arr = [];
Object.keys(jsonObj).map((zone, index) => {
arr.push(jsonObj[zone]);
})
return(
<div>
<p> interpretJson output: </p>
<ul>
{arr.map(item => {
item.type
})
}
</ul>
</div>
)
}
}
Displaying the output is only meant to see if it is being iterated correctly, so I can proceed to the switch case, but apparently something is not right.
{arr.map(item => <li>item.type</li> )}