I've been grappling with iterating through a JSON that contains a map within a map for hours, but have had no success...
Here is the JSON string:
{
"P31": {
"wikibase-entityid": "Q16603799"
},
"P227": {
"string": "1084653095"
},
"P1001": {
"wikibase-entityid": "Q183"
},
"P1448": {
"monolingualtext": "Verordnung über Sicherheit und Gesundheitsschutz bei der Verwendung von Arbeitsmitteln"
},
"P1813": {
"monolingualtext": "Betriebssicherheitsverordnung"
},
"P7677": {
"string": "betrsichv_2015"
},
"P580": {
"time": "+2002-10-03T00:00:00Z"
},
"P2671": {
"string": "/g/1224z0c0"
},
"P9696": {
"string": "11477"
}
}
For a visual guide, refer to this image: https://i.sstatic.net/KbI4q.png
Please note that each property can have multiple values.
Essentially, I am looking to create a loop in which I have access to the property (e.g. PXXX), the type of the property (key in the inner map), and the value of the property (value in the inner map).
I've attempted to convert the string into a Map using methods like "new Map(JSON.parse(jsonStr))", "new Map(Object.entries(jsonStr))", and others, but without success.
Furthermore, my attempts at iterating through it with "for (var key in obj)" and "myMap.forEach((value_propertyInfo, key_propertyName) => {...}" have also been unsuccessful.
At times it feels like I'm iterating character by character, while other times it simply throws an error stating that the map is not iterable.
If anyone has any suggestions on what alternative approach I should be taking, I would greatly appreciate it!
Thank you!