java - Parse JSON string by escaping characters -


i receiving below string db.

{     "mydetails": {         "type1": "a",         "type2": "b",         "type3": "c",         "type4": "d",         "type5": "e",         "type6": "f",         "date1": "2000-02-11"     } } 

i have created syntax parse json string above format giving me error string not able construct string.

jsonobject obj = new jsonobject("{mydetails:{type: a,class: b}}"); system.out.println(obj); jsonobject array = obj.getjsonobject("mydetails"); system.out.println(array); (int = 0; < array.length(); i++) {   system.out.println(array.getstring("class")); } 

how convert string db valid string in java?

i guess should give me answer .

the problem string data received db , not able convert string.

how remove quotes dynamically can form valid string?

to parse json

{     "mydetails": {         "type1": "a",         "type2": "b",         "type3": "c",         "type4": "d",         "type5": "e",         "type6": "f",         "date1": "2000-02-11"     } } 

you use this:

jsonobject root = ...; jsonobject details = (jsonobject) root.get("mydetails"); string type1 = (string) details.get("type1"); string type2 = (string) details.get("type2"); // , on 

Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

android - Keyboard hides my half of edit-text and button below it even in scroll view -

css - Make div keyboard-scrollable in jQuery Mobile? -