Note that there are some explanatory texts on larger screens.

plurals
  1. POParse JSONArray inside JSONArray
    text
    copied!<p>I am using <a href="https://code.google.com/p/google-gson/" rel="nofollow">Gson</a> for parsing json response. I need to parse JSONArry inside JsonArray..</p> <p>My response is..</p> <pre><code>{ "message": "Retreive sucessfully", "flag": true, "data": { "myArray1": [[{ "xyz": "1400.0", "abc": "O", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "J", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "I", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "D", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "C", "mnp": "leeper" }], [{ "xyz": "1400.0", "abc": "M", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "L", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "G", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "F", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "A", "mnp": "leeper" }]], "myArray2": [[{ "xyz": "1000.0", "abc": "notaes", "mnp": null }], [{ "xyz": "1400.0", "abc": "LS5", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "LS4", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "LS3", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "LS2", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "LS1", "mnp": "leeper" }], [{ "xyz": "1000.0", "abc": "19", "mnp": "taes" }, { "xyz": "1000.0", "abc": "notaes", "mnp": null }, { "xyz": "1000.0", "abc": "notaes", "mnp": null }, { "xyz": "1000.0", "abc": "notaes", "mnp": null }, { "xyz": "1000.0", "abc": "notaes", "mnp": null }, { "xyz": "1000.0", "abc": "notaes", "mnp": null }, { "xyz": "1000.0", "abc": "notaes", "mnp": null }, { "xyz": "1000.0", "abc": "notaes", "mnp": null }, { "xyz": "1000.0", "abc": "notaes", "mnp": null }, { "xyz": "1000.0", "abc": "notaes", "mnp": null }], [{ "xyz": "1000.0", "abc": "notaes", "mnp": null }, { "xyz": "1000.0", "abc": "notaes", "mnp": null }, { "xyz": "1000.0", "abc": "20", "mnp": "taes" }, { "xyz": "1000.0", "abc": "6", "mnp": "taes" }, { "xyz": "1000.0", "abc": "3", "mnp": "taes" }, { "xyz": "1000.0", "abc": "2", "mnp": "taes" }], [{ "xyz": "1000.0", "abc": "notaes", "mnp": null }, { "xyz": "1000.0", "abc": "1", "mnp": "taes" }]] }, "code": "99" } </code></pre> <p>What should be my class? I have done like this...</p> <pre><code>public class MyLayout { public String message; public boolean flag; public Data data; public String commandName; public String code; public class Data { public ArrayList&lt;MyClass&gt; myArray1 = new ArrayList&lt;MyLayout.MyClass&gt;(); public ArrayList&lt;MyClass&gt; myArray2 = new ArrayList&lt;MyLayout.MyClass&gt;(); } public class MyClass { public String abc; public String xyz; public String mnp; } } </code></pre> <p>It's not working??</p> <p><strong>EDIT</strong></p> <p>My Above <code>MyLayout</code> works when response is like below..But what about <code>myArray</code> item also contains <code>JSONArray</code></p> <pre><code>{ "message": "Retreive sucessfully", "flag": true, "data": { "myArray1": [{ "xyz": "1400.0", "abc": "O", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "J", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "I", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "D", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "C", "mnp": "leeper" }], "myArray2": [{ "xyz": "1400.0", "abc": "LS5", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "LS4", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "LS3", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "LS2", "mnp": "leeper" }, { "xyz": "1400.0", "abc": "LS1", "mnp": "leeper" }] }, "code": "99" } </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