I have a stack with parsing JSON object in Android.
Here my JSON Data,
{
STATUS: "200"
ERROR: "false"
SECRETKEY: "deb1d0b9a70a0ed682d2975b2a583c28"
DATA: {
stock: 2
pins: [1]
0: {
id: "1"
pin: "8172310874"
serial: "0000000000100000"
card_type: "10000"
company: "FWIFI"
expiry_date: "2016-01-01"
invoice_id: "INVHQ/000001"
order_id: "1"
delivered: "0"
}
}
}
Here my parsing json object
try {
JSONObject json = new JSONObject(value);
String secretKey = json.get("SECRETKEY").toString();
JSONObject data_obj = new JSONObject("DATA"); //problem is here. It's go to catch block
JSONArray j_array = data_obj.getJSONArray("pins");
Integer qty = j_array.length();
for(int i = 0 ; i < j_array.length() ; i++){
//here loop
}
}catch (JSONException e) {
e.printStackTrace();
}
Please pointing me how can I loop? I change this. But, error say like that.
Value DATA of type java.lang.String cannot be converted to JSONObject
{is ajsonObject, notjsonArray