Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Try using </p> <pre><code>Class JsonGotText{ String status; HashMap&lt;String, Object&gt; result; } </code></pre> <p>If performance is not key criteria here. You better use 'JSONObject' without worrying the structure of JSON String. </p> <hr> <p>Ideally, you should write a POJO. Say <code>EventPOJO</code> that has attributes same as as each result object holds and then make the Java class as </p> <pre><code>Class JsonGotText{ String status; HashMap&lt;String, EventPOJO&gt; result; } </code></pre> <p>you may have to use a type token <a href="https://sites.google.com/site/gson/gson-user-guide#TOC-Serializing-and-Deserializing-Generic-Types" rel="nofollow">see here</a>, but will save your efforts later.</p> <p><strong>Update</strong><br> It seems the sentence above sounds confusing. Here is clarification what I wanted <code>EventPOJO</code> to represent to. The EventPOJO will represents things like </p> <pre><code>{ "type": "event", "decorated_time": 1346048488, "guidOwner": 90, "title": null, "action_type": "event_relationship", "summary": "river:event_relationship:object:event", "annotation": null, "group": "" } </code></pre> <hr> <p><strong>Update1</strong> @LalitPoptani asked for exact working code. Here it is! </p> <p>Here is an working example:</p> <pre><code>public class Test { private static String json = "{"+ "\"status\": 0,"+ "\"result\": {"+ "\"1346053628\": {"+ "\"type\": \"default\","+ "\"decorated_time\": 1346053628,"+ "\"guidOwner\": 13716"+ "},"+ "\"1346051675\": {"+ "\"type\": \"event\","+ "\"decorated_time\": 1346051675,"+ "\"guidOwner\": 90"+ "},"+ "\"1346048488\": {"+ "\"type\": \"event\","+ "\"decorated_time\": 1346048488,"+ "\"guidOwner\": 90"+ "}"+ "}" + "}"; public static class Event{ String type; Long decorated_time; Integer guidOwner; } public static class JSON{ Integer status; HashMap&lt;Long, Event&gt; result; } public static void main(String[] args){ Gson gson = new Gson(); System.out.println("JSON: " + json); JSON j = gson.fromJson(json, JSON.class); for(Entry&lt;Long, Event&gt; e: j.result.entrySet()){ System.out.println(e.getKey() + ": " + e.getValue().guidOwner); } } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload