JSON parsing problem
Monkey Forums/Monkey Beginners/JSON parsing problem| 
 | ||
| Hi, I'm coding an html 5 app and to load my game level, i want to use json files. So, to give it a try, i have wrote a sample json file and i use the muddy_shoes's lib to parse it. My code : 
	Local str:= LoadString("test.json")
		
		Local data:JSONDataItem = JSONData.ReadJSON(str)
		Local jsonObject:JSONObject = JSONObject(data)
		
		For Local a:= EachIn jsonObject.Names()
			Print a
		Next
My Json : {"test1":"value1","test2":"value2","test3":"value3"}But when i start my app, the console showing this output : test1 test2 test3 Monkey Runtime Error : Array index out of range Thanks for the help. | 
| 
 | ||
| I just ran this with the same lib... Import json
Function Main()
	Local str:= "{~qtest1~q:~qvalue1~q,~qtest2~q:~qvalue2~q,~qtest3~q:~qvalue3~q}"
	
	Local data:JSONDataItem = JSONData.ReadJSON(str)
	Local jsonObject:JSONObject = JSONObject(data)
	
	For Local a:= EachIn jsonObject.Names()
		Print a
	Next
EndThis was the output test1 test2 test3 So it looks like this code is working just fine. | 
| 
 | ||
| Yes, i tried like you to launch this part of code in a new file and it's appears to work. I can't figure out why with my whole code, i have a "Monkey Runtime Error : Array index out of range" error. EDIT : Ok i found it why. It was not related with the parse of my json. |