Re: [json-lib-user] Quick Question on JSON
Brought to you by:
aalmiray
From: Andres A. <aal...@ya...> - 2007-12-11 21:04:27
|
Hi Haritha,=0A=0AYou are right, if it is a nested JSONObject it should prin= t it without the surrounding double quotes. As a last resort, can you call= =0A=0AJSONObject jsonObj =3D JSONObject.fromObject( textField, jsonConfig )= ;=0AJSONObject json =3D json.getJSONObject( "JSON" );=0A=0AIf it really is = a JSONObject then no exception should arise. If no exception is thrown then= there may be something going on with the string representation of a JSONOb= ject when printed.=0A=0AThanks,=0AAndres=0A=0A=0A----- Original Message ---= -=0AFrom: Haritha Juturu <har...@ya...>=0ATo: Andres Almiray <a= al...@ya...>; jso...@li...=0ASent: Tuesday, De= cember 11, 2007 12:59:32 PM=0ASubject: Re: [json-lib-user] Quick Question o= n JSON=0A=0A=0AHi Andres=0A=0AThe TextField bean looks like this=0Apublic c= lass TextField(){ =0A private Long parentId;=0A private Long textField= Id;=0A private String JSON;=0A}=0A=0AAfter executing the code JSONObject= jsonObj =3D JSONObject.fromObject( textField, jsonConfig ); , i try to pr= int this object 'jsonObj" and it prints the name value pair( of JSON Proper= ty) with quotes=0A=0A{"parentId":678,"textFieldId":111,"JSON":"{'sizeWidth'= :620,'text':'=93[Winning the Nobel Peace Prize]=0A ','positionLeft':20,'sty= le':'left:20px;top:100px;width:620px;height:100px;','positionTop':100,'name= ':'','cssClass':'','objectType':'TextObject','sizeHeight':100}"}=0A=0AIf it= was converting this 'JSON' property to JSONObject internally, wont it prin= t as=0A=0A"JSON":=0A{"parentId":678,"textFieldId":111,"JSON":{'sizeWidth':6= 20,'text':'=93[Winning=0Athe Nobel Peace Prize]=0A','positionLeft':20,'styl= e':'left:20px;top:100px;width:620px;height:100px;','positionTop':100,'name'= :'','cssClass':'','objectType':'TextObject','sizeHeight':100}}=0Awithout th= e quotes on the value.=0A=0APlease correct me if i got it wrong=0A=0AI am u= sing the json-lib-2.1 for jsd 1.5 version.=0AHaritha=0A=0A=0A=0A----- Origi= nal Message ----=0AFrom: Andres Almiray <aal...@ya...>=0ATo: Haritha = Juturu <har...@ya...>; jso...@li...=0ASe= nt: Tuesday, December 11, 2007 12:27:12 PM=0ASubject: Re: [json-lib-user] Q= uick Question on JSON=0A=0A=0AHi Haritha,=0A=0AAre you sure the contents of= the named property ('JSON') are not automatically converted into a JSONObj= ect ? it looks to me like it is a well formed json string, if so it should = be converted automatically when you call fromObject() at top level.=0A=0ACa= n you please tell us which version of Json-lib are you testing with?=0A=0AR= egards,=0AAndres=0A=0A----- Original Message ----=0AFrom: Haritha Juturu <h= ari...@ya...>=0ATo: jso...@li...=0ASent: = Tuesday, December 11, 2007 12:16:36 PM=0ASubject: [json-lib-user] Quick Que= stion on JSON=0A=0A=0AHi Everyone=0AI have a line of code=0AJSONObject json= Obj =3D JSONObject.fromObject( textField, jsonConfig ); =0Awhich produces = this JSON string=0A=0A{"parentId":678,"textFieldId":111,=0A"JSON":=0A"{'siz= eWidth':620,'text':'=93[Winning the Nobel Peace Prize]','positionLeft':20,'= style':'left:20px;top:100px;width:620px;height:100px;','positionTop':100,'n= ame':'','cssClass':'','objectType':'TextObject','sizeHeight':100}"=0A}=0A= =0Anow if i want the property "json" whose value is a string=0A =93[Winning= the Nobel Peace=0APrize]','positionLeft':20,'style':'left:20px;top:100px;w= idth:620px;height:100px;','positionTop':100,'name':'','cssClass':'','object= Type':'TextObject','sizeHeight':100}"=0A=0Ato be converted to a json object= .... is there any API methods i can use.i am unable to locate any.=0A=0Ai.= e my output should look like =0A{"parentId":678,"textFieldId":111,=0A"JSON= ": this value is not a string anymore=0A{'sizeWidth':620,'text':'=93[Winnin= g=0Athe Nobel Peace=0APrize]','positionLeft':20,'style':'left:20px;top:100p= x;width:620px;height:100px;','positionTop':100,'name':'','cssClass':'','obj= ectType':'TextObject','sizeHeight':100}=0A}=0A=0AI have a constraint that i= need to do this manipulation on the jsonObj .=0A=0AThanks=0AHaritha=0A=0A= =0A=0A=0A=0A=0A Be a better friend, newshound, and =0Aknow-it-all with= Yahoo! Mobile. Try it now.=0A=0A=0A=0A=0A=0A Be a better friend, new= shound, and =0Aknow-it-all with Yahoo! Mobile. Try it now.=0A=0A=0A=0A=0A= =0A Looking for last minute shopping deals? =0AFind them fast with Ya= hoo! Search.=0A=0A=0A=0A=0A=0A _______________________________________= _____________________________________________=0ABe a better friend, newshou= nd, and =0Aknow-it-all with Yahoo! Mobile. Try it now. http://mobile.yaho= o.com/;_ylt=3DAhu06i62sR8HDtDypao8Wcj9tAcJ =0A |