json parse/Eachin sort order info

Monkey Forums/Monkey Programming/json parse/Eachin sort order info

GC-Martijn(Posted 2015) [#1]
Just for other people that working with json files.
The parse order is not the same as the file.

{
 "w":2048,
 "h":768,
 "p":200,
 "data":{
 	"world":{
 		"z":1,
 		"atlas":"atlas-scene1.json"
 	},
 	"player":{
 		"z":2,
	 	"atlas":"atlas-lopen.json",
	 	"initFrameKey":"looprechts",
	 	"initX":800,
	 	"initY":712
 	}
 }
}


Local jso:JsonObject = New JsonObject(str)
For Local it:map.Node<String, JsonValue> = Eachin JsonObject( jso.Get("data") ).GetData()
Print it.Key
Next


Output:
player
world


k.o.g.(Posted 2015) [#2]
Thats the functionality of Stringmaps..:



Output:
abc
hehe
world
zabc



nullterm(Posted 2015) [#3]
If you want them in order, then you need an JsonArray using [], not an JsonObject {}.



Or, you access things by name if using a JsonObject [].