Iterate over Json Object in typescript
Clash Royale CLAN TAG#URR8PPP
Sorry for the inconvenience added the JSON structure now. hope it is useful.
– teja sri
16 hours ago
.map only works on arrays. You would need to iterate through the object. You can check here for some examples: stackoverflow.com/questions/921789/…. But in your case, since you are using typescript, I would suggest transforming the examples to typescript.
– Gregor Ojstersek
16 hours ago
Consider building a stackblitz with an example of the JSON structure and the code you've tried to use to iterate it. That will help us help you.
– DeborahK
14 hours ago
Please find the image, which shows the JSON structure
– teja sri
14 hours ago
Iterate over Json Object in typescript
I have a scenario where a HTTP request results in a json Object with a Map collection. on the client side I had captured this object into a variable result but this variable is an object which encapsulates the Map collection. In order to process the data I have to iterate over this Map. How can I do this??
The JSON structure is like this
let result:Map=Object key1,val1,key2,val2,key3,val3,etc;
if i try to iterate over this result variable an "get is not a function" error is thrown which shows that result is not actually a map but an Object.
Sorry for the inconvenience added the JSON structure now. hope it is useful.
– teja sri
16 hours ago
.map only works on arrays. You would need to iterate through the object. You can check here for some examples: stackoverflow.com/questions/921789/…. But in your case, since you are using typescript, I would suggest transforming the examples to typescript.
– Gregor Ojstersek
16 hours ago
Consider building a stackblitz with an example of the JSON structure and the code you've tried to use to iterate it. That will help us help you.
– DeborahK
14 hours ago
Please find the image, which shows the JSON structure
– teja sri
14 hours ago
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
it would help to share an example of your data. also take some time to read the how to ask a good question guide. stackoverflow.com/help/how-to-ask
– toskv
16 hours ago