JSON Creation from Java -


hi new json , have create below json java.

{{ "testmain" : { "test1" : { "384" : "250", "96" : "450" },            "test2" :{ "384" : "5", "96" : "10" },            "test3" : "256",            "test4" : "t" } 

i have created each object using jsonobject.put. how combine 4 test objects text testmain. idea?

the json library awfully verbose, should need:

final jsonobject wrapper = new jsonobject(); final jsonobject inner = new jsonobject(); final jsonobject innersub1 = new jsonobject(); innersub1.put("384", "250"); innersub1.put("96", "450"); final jsonobject innersub2 = new jsonobject(); innersub2.put("384", "5"); innersub2.put("96", "10"); inner.put("test1", innersub1); inner.put("test2", innersub2); inner.put("test3", "256"); inner.put("test4", "t"); wrapper.put("testmain", inner); system.out.println(wrapper.tostring()); 

i advise @ more modern json libraries gson or jackson, because make life lot simpler!


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -