I'm using HttpClient to get the response of a webservice (REST
servlet) which is a JSON string.
This string represents a JSONArray of type Map with key "mybeans".
I'd like to assemble my bean using the JSON string.
Usually I use net.sf.json json-lib and do something like this:
String s = jsonStringIGotFromResponse;
Map<String, List> bean = (Map<String, List>) JSONObject.toBean(
JSONObject.fromObject(s), Map.class);
List myBeans = bean.get("mybeans");
JSONArray jsonArray = JSONArray.fromObject(myBeans);
List<MyBean> myBeansToReturn = new ArrayList<MyBean>();
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
MyBean myBean = (MyBean)JSONObject.toBean(jsonObject,
MyBean.class);
myBeansToReturn.add(myBean);
}
I have no idea how to write something similar using the org.json
classes provided by the Android.jar
Could anyone help me out with this please?
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en