Hi All/Andres,
I have a json string
String inputJsonString ={\"id\":\"120093773707853925\",
\"parent_id\":\"120093773303118315\",
\"objectType\":\"DataTableObject\",
\"jsonData\":
{
\"objectType\":\"DataTableObject\",
\"id\":\"120093773707853925\",
\"name\":\"\",
\"position\":\"({left:320, top:200})\",
\"size\":\"({width:620, height:300})\",
\"cssClass\":\"\",
\"style\":\"left:320px;top:200px;width:620px;height:300px;\",
\"dataSource\":\"exampleData.json\",
\"objects\":[{name:\"col1\", friendlyName:\"Column 1\"},{name:\"col2\", friendlyName:\"Column 2\"},{name:\"col3\", friendlyName:\"Column 3\"},{name:\"col4\", friendlyName:\"Column 4\"},{name:\"col5\", friendlyName:\"Column 5\"}]
},
\"orderIndex\":0
}
and a JavaBean
public class ChildItem{
private Long id;
private Long parent_id;
private String objectType;
private Integer orderIndex;
private String jsonStr;
private JSONObject jsonData;
private List objects;
}
Java code to capture json string in ChildItem is
JsonConfig jConfig = new JsonConfig();
jConfig.setRootClass(ChildItem.class);
jsonObject = JSONObject.fromObject( itemList.get(i),jConfig);
objectType=jsonObject.getString("objectType");
log.debug("Object Type is:"+objectType);
log.debug("json value is : "+jsonObject.getJSONObject("json"));
child = (ChildItem)JSONObject.toBean(jsonObject ,ChildItem.class);
on the last line child = (ChildItem)JSONObject.toBean(jsonObject ,ChildItem.class); , i get this exception
net.sf.json.JSONException: Error while setting property=columns type interface java.util.List
When i convert json string to java object, the property 'jsonData' is captured as JSONObject as desired. But i dont want to process it further. but looks like JSON-lib is processing the value of 'jsonData' property , how can i avoid this??
Thanks
Haritha
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs |