I followed this tutorial on how to decode json with java: https://code.google.com/p/json-simple/wiki/DecodingExamples
In my project i get info_string:
{"server_ip":"http://localhost:3000/","device_id":14}
that i would like to decode: I tried:
System.out.println(info_string);
=> {"server_ip":"http://localhost:3000/","device_id":14}
Object obj = JSONValue.parse(info_string);
System.out.println(obj);
=> null
JSONArray array=(JSONArray)obj;
=> null
System.out.println(array);
As you can see the array and obj variable are null and contain no data!
What do i wrong? Thanks
String info_string = "\u0000{\"server_ip\":\"http://localhost:3000/\",\"device_id\":14}";would demonstrate the behavior you are seeing. Otherwise it's working fine for me (until you try to castobjto aJSONArraybut that's another story).info_string.trim()works! Could you please write an answer?device_idfrom thisobj? Thanks!