Re: [json-lib-user] Fw: Dont want to process JSONObject variable in JavaBean
Brought to you by:
aalmiray
From: Andres A. <aal...@ya...> - 2008-01-21 19:42:47
|
Haritha, If I understand correctly, you'll want 'jsonData' to either be stored as a JSONObject or a String back into your Java bean ? instead of being transformed into another bean or DynaBean ? ------------------------------------------- http://jroller.com/aalmiray http://www.linkedin.com/in/aalmiray -- What goes up, must come down. Ask any system administrator. There are 10 types of people in the world: Those who understand binary, and those who don't. To understand recursion, we must first understand recursion. ----- Original Message ---- From: Haritha Juturu <har...@ya...> To: jso...@li... Sent: Monday, January 21, 2008 11:34:08 AM Subject: [json-lib-user] Fw: Dont want to process JSONObject variable in JavaBean Hi All, I have made some changes to post that are in blue. Thanks Haritha ----- Forwarded Message ---- From: Haritha Juturu <har...@ya...> To: jso...@li... Sent: Monday, January 21, 2008 10:35:52 AM Subject: [json-lib-user] Dont want to process JSONObject variable in JavaBean 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=objects 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 homepage. Looking for last minute shopping deals? Find them fast with Yahoo! Search. ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs |