I have a json string (Qaiku social network stream). How can I decode it in Java? I searched, but any results work for me. Thank.
As an example using Gson, you can do the following
Gson gson = new Gson(); gson.fromJson(value, type);
where value is your encoded value. The trick comes with a second parameter - type. You need to know what your decoding is and what type of Java JSON will end with.
The following example decodes a JSON string into a list of domain objects called Table:
http://javastorage.wordpress.com/2011/03/31/how-to-decode-json-with-google-gson-library/
To do this, the type must be specified as:
Type type = new TypeToken<List<Table>>(){}.getType();
Gson is available here:
http://code.google.com/p/google-gson/
- :
Gson gson = new Gson(); MyType obj = gson.fromJson(json, MyType.class);
MyType.
Gson. - , JSON.