I am facing the issue in reading the json array from the json object
{ "DS": {
"LST": [
{
"OID": 1,
"OCD": "1",
"OPE": "AIRCEL",
"IPH": "Images/provider/aircelsm.jpg",
"MIL": 10,
"MXL": 10
},
{
"OID": 2,
"OCD": "3",
"OPE": "AIRTEL",
"IPH": "Images/provider/airtelsm.jpg",
"MIL": 10,
"MXL": 10
},
{
"OID": 22,
"OCD": "BSR",
"OPE": "BSNL SPL RECHARGE",
"IPH": "",
"MIL": 0,
"MXL": 0
},
{
"OID": 4,
"OCD": "4",
"OPE": "BSNL Topup",
"IPH": "Images/provider/bsnlsm.jpg",
"MIL": 10,
"MXL": 10
},
{
"OID": 6,
"OCD": "5",
"OPE": "DOCOMO",
"IPH": "Images/provider/docomosm.jpg",
"MIL": 10,
"MXL": 10
},
{
"OID": 7,
"OCD": "6",
"OPE": "IDEA",
"IPH": "Images/provider/ideasm.jpg",
"MIL": 10,
"MXL": 10
},
{
"OID": 8,
"OCD": "7",
"OPE": "MTS",
"IPH": "Images/provider/mtssm.jpg",
"MIL": 10,
"MXL": 10
},
{
"OID": 5,
"OCD": "8",
"OPE": "RELAINCE",
"IPH": "Images/provider/reliancesm.jpg",
"MIL": 10,
"MXL": 10
},
{
"OID": 3,
"OCD": "9",
"OPE": "VODAFONE",
"IPH": "Images/provider/vodafonesm.jpg",
"MIL": 10,
"MXL": 10
}
],
"LST1": [
{
"OID": 10,
"OCD": "0",
"OPE": "AIRTEL DTH",
"IPH": "Images/provider/airtelsm.jpg",
"MIL": 10,
"MXL": 10
},
{
"OID": 11,
"OCD": "0",
"OPE": "BIGTV",
"IPH": "Images/provider/aircelsm.jpg",
"MIL": 10,
"MXL": 10
},
{
"OID": 12,
"OCD": "0",
"OPE": "DISH TV",
"IPH": "Images/provider/dishtvsm.jpg",
"MIL": 10,
"MXL": 10
},
{
"OID": 9,
"OCD": "0",
"OPE": "SUN DIRECT",
"IPH": "Images/provider/sundirectsm.jpg",
"MIL": 10,
"MXL": 10
},
{
"OID": 13,
"OCD": "0",
"OPE": "TATA SKY",
"IPH": "Images/provider/tataskysm.jpg",
"MIL": 10,
"MXL": 10
},
{
"OID": 14,
"OCD": "0",
"OPE": "VIDEOCON DTH",
"IPH": "Images/provider/videoconsm.jpg",
"MIL": 10,
"MXL": 10
}
]
}
}
The above json data is from server and how to read the json array in that .
My model class for reading json data are
public class SpinnerRootObject {
@SerializedName("DS")
SpinnerMenuItems ds;
public SpinnerMenuItems getDs() {
return ds;
}
public void setDs(SpinnerMenuItems ds) {
this.ds = ds;
}
}
public class SpinnerMenuItems
{
@SerializedName("LST")
ListZero zeroList;
@SerializedName("LST1")
String firstList;
public ListZero getZeroList() {
return zeroList;
}
public void setZeroList( ListZero zeroList) {
this.zeroList = zeroList;
}
public String getFirstList() {
return firstList;
}
public void setFirstList(String firstList) {
this.firstList = firstList;
}
}
public class ListZero {
@SerializedName("IPH")
String images;
@SerializedName("OID")
String oid;
@SerializedName("OPE")
String ope;
@SerializedName("OCD")
String ocd;
@SerializedName("MIL")
String mil;
@SerializedName("MXL")
String mxl;
public String getMxl() {
return mxl;
}
public void setMxl(String mxl) {
this.mxl = mxl;
}
public String getMil() {
return mil;
}
public void setMil(String mil) {
this.mil = mil;
}
public String getOcd() {
return ocd;
}
public void setOcd(String ocd) {
this.ocd = ocd;
}
public String getOpe() {
return ope;
}
public void setOpe(String ope) {
this.ope = ope;
}
public String getOid() {
return oid;
}
public void setOid(String oid) {
this.oid = oid;
}
public String getImages() {
return images;
}
public void setImages(String images) {
this.images = images;
}
}
The above code are model class for reading json.
The code used for reading the json from server is
Gson gson = new Gson();
SpinnerRootObject spinnerRootObject = gson.fromJson(result.getResult(), SpinnerRootObject.class);
settingDropDown((List<SpinnerRootObject>) spinnerRootObject);
While using the above method the exception is occurred Caused by: java.lang.IllegalStateException: Expected BEGIN_OBJECT but was BEGIN_ARRAY at line 1 column 15 path . i don't know how to read the json array in given json data
I need to pass the json arraylist data into the custom adapter
public void settingDropDown( List<SpinnerRootObject> selectedNetwork)
{
customAdapter = new Fragment_DTH_Main_Spinner_Adapter
(getActivity(),R.layout.fragment_dth_main_spinner_items,R.id.serviceName,selectedNetwork);
selectMenu.setAdapter(customAdapter);
}
Please help me how to get the json array from the json object