JSON応答の解析にGsonを使用しています。JsonArray 内で JSONArry を解析する必要があります。
私の返事は..
{
"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"
}
私のクラスは何ですか?私はこのようにしました...
public class MyLayout {
public String message;
public boolean flag;
public Data data;
public String commandName;
public String code;
public class Data {
public ArrayList<MyClass> myArray1 = new ArrayList<MyLayout.MyClass>();
public ArrayList<MyClass> myArray2 = new ArrayList<MyLayout.MyClass>();
}
public class MyClass {
public String abc;
public String xyz;
public String mnp;
}
}
動いていない??
編集
私の上記は、応答が以下のような場合に機能します..しかし、アイテムにはMyLayout
何が含まれていますかmyArray
JSONArray
{
"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"
}