Hello I have been trying to read a JSON file in java using the json.simple library, I read more than a dozen of tutorials on how to do this but in the end the way my JSON file is written is causing me a lot of trouble.
{
"0": {
"POI": "43df8ad6f964a520b92e1fe3",
"latitude": 40.731356448341,
"longitude": -73.988671302795,
"photos": "https:\/\/irs3.4sqi.net\/img\/general\/612x612\/343235_eezF7KZ55QpdVVNuMTFOO86bikjUbmrxb1IEuf2C1uI.jpg",
"POI_category_id": "Arts & Entertainment",
"POI_name": "AMC Loews Village 7"
},
"1": {
"POI": "4bfec352daf9c9b64038f9ef",
"latitude": 40.75358312925,
"longitude": -74.214450350548,
"photos": "https:\/\/irs1.4sqi.net\/img\/general\/540x720\/c5xfqE_ajHOZb1LBtUBEdYNlc9aQ12EoPcavI_dVkDw.jpg",
"POI_category_id": "Food",
"POI_name": "Wendy's"
}
...
}
My issue is that I have no idea how I can get the first value "0":, "1": without having a key next to so I could use the .get("KEY") function.
I tried something like jsobj.get(i) and then increasing the value of i by one every time but that didn't work at all.
This is my first time trying to do something with json so I have no idea if what I am trying to do is right. Thanks in advance
org.jsonlibrary forJSONrepresentation, you can read the entire file and store the content in aStringBuilder, and then use thatStringBuilder.toString()to instantiate anew JSONObject(StringBuilder.toString()).iwould need to be a string in this case. Can you include a minimal reproducible example so we can see what's going on?