i have following sample json:
{\"2013-05-30\":{\"available\":\"1\",\"bind\":0,\"info\":\"\",\"notes\":\"\",\"price\":\"\",\"promo\":\"\",\"status\":\"available\"}, \"2013-05-31\":{\"available\":\"1\",\"bind\":0,\"info\":\"\",\"notes\":\"\",\"price\":\"\",\"promo\":\"\",\"status\":\"available\"}, \"2013-06-01\":{\"available\":\"1\",\"bind\":0,\"info\":\"\",\"notes\":\"\",\"price\":\"\",\"promo\":\"\",\"status\":\"available\"}}
i read string , parse jsonobject, need in jsonarray. have tried adding programmatically "[" @ beginning of string , "]" @ end of it, before convert jsonarray, and, although recognizes array, still sees single object (i seem have jsonarray(0)).
this how try parse jsondata array:
try{ jarray = new jsonarray(resultstring); for(int i=0;i<jarray.length();i++){ jsonobject json_data = jarray.getjsonobject(i); log.i("log_4","available: "+json_data.getstring("available")+ ", bind: "+json_data.getstring("bind")+ ", info: "+json_data.getstring("info") + ", notes: "+json_data.getstring("notes") + ", price: "+json_data.getstring("price") + ", promo: "+json_data.getstring("promo") + ", status: "+json_data.getstring("status") ); } }catch(jsonexception e){ log.e("log_5", "error parsing data "+e.tostring()); }
and here version in don't add [ , ], therefore parsing jsonobject.
try { jsonresponse = new jsonobject(resstring); } catch (jsonexception e) { log.e("log_3", "error parsing data "+e.tostring()); }
how can separate each day (e.g."2013-05-30") different object, each object having key value of day?
thanks lot!
instead of adding [
@ begining , ]
@ end, try replacing first instance of {
[
, last instance of }
]
, making jsonarray out of it.
Comments
Post a Comment