سؤال

{ "period" : 5, "externs" : { "lots" : { "start" : 1, "step" : 0, "stop" : 2 } } }

I'm trying to convert the above JSON string to a JSONObject using simple-json. I do it by:

JSONObject obj = new JSONParser().parse(str);

the problem is that the parser somehow change the variables order to:

{ "externs" : { "lots" : { "stop" : 2 , "start" : 1 , "step" : 0 } } , "period" : 5 }

And I want to keep the exactly same order as in the beginning , any hints?

هل كانت مفيدة؟

المحلول

What you want opposes how JSON objects are specified: an unordered list of key/value pairs.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top