Re: [json-lib-user] Exception while parsing JSON
Brought to you by:
aalmiray
From: Andres A. <aal...@ya...> - 2008-01-17 21:23:13
|
Hi Haritha, The answer is in the JSON spec (http://json.org/), parenthesis are now allowed outside quotes. Please take a look at the grammar of 'value' in the spec. Do you require the parenthesis ? if so you would need to surround the value with quotes. cheers, Andres ------------------------------------------- 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: Thursday, January 17, 2008 1:18:29 PM Subject: [json-lib-user] Exception while parsing JSON Hi All , I have a json string defined below which i am trying to convert into a java object TestObject.java String jsonStr="{\"id\":\"123456\",\"name\":\"untitled note\",\"json\":{\"name\":\"hjsgdfhjgsdfh\"},\"size\":({width:941,height:480})}"; JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setRootClass(TestObject.class); jsonObject = JSONObject.fromObject(jsonStr,jsonConfig); Object object = JSONObject.toBean(jsonObject ,TestObject.class); When i execute this code i get this exception ERROR - RequestCycle.logRuntimeException(1328) | Unquotted string '(' net.sf.json.JSONException: Unquotted string '(' at net.sf.json.util.JSONTokener.nextValue(JSONTokener.java:445) at net.sf.json.JSONObject._fromJSONTokener(JSONObject.java:913) at net.sf.json.JSONObject._fromString(JSONObject.java:1102) at net.sf.json.JSONObject.fromObject(JSONObject.java:175) at com.splashnote.web.pages.Test.<init>(Test.java:41) Can someone tell me how i can avoid this. The "size" parameter value is treated as what object in json-lib? Thanks Haritha Never miss a thing. Make Yahoo your homepage. ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping |