Re: [json-lib-user] Incompatibilities in encoding JSON objects
Brought to you by:
aalmiray
From: Thomas W. <tho...@du...> - 2009-01-11 12:44:31
|
Thanks Morgan,I did try this, and it does force json-lib to put quotes around the value, however it then also adds the quotes that I've put in manually! So you end up with: { "key" : "\"function(value){}\"" } Tom 2009/1/10 Morgan Packard <mpa...@ke...> > just a guess, I should say. But that's what I'd try first. > > > On Sat, Jan 10, 2009 at 6:11 PM, Morgan Packard <mpa...@ke...>wrote: > >> escape the quotes. >> >> I think: >> >> obj.accumulate("key","\"function(value){}\""); >> >> On Sat, Jan 10, 2009 at 4:33 PM, Thomas Williams < >> tho...@du...> wrote: >> >>> Hi Chaps, I have noticed a difference in the encoding of JSON objects >>> when the key I am encoding looks like a Javascript function. If I try the >>> following: >>> >>> >>> final JSONObject obj = new JSONObject(); >>> obj.accumulate("key","value"); >>> System.out.println(obj.toString()); >>> >>> It outputs: >>> >>> {"key" : "value"} >>> >>> If however I try this instead: >>> >>> final JSONObject obj = new JSONObject(); >>> obj.accumulate("key","function(value){}"); >>> System.out.println(obj.toString()); >>> >>> It outputs: >>> >>> {"key" : function(value){}} >>> >>> Note the lack of quote marks around the value. Is there any way I can >>> force it to add quote marks around that value? >>> >>> regards, >>> Tom >>> >>> -- >>> Thomas Williams >>> Java Programmer >>> Dubit Limited >>> +44 1133 947920 >>> www.dubitlimited.com >>> >>> >>> ------------------------------------------------------------------------------ >>> Check out the new SourceForge.net Marketplace. >>> It is the best place to buy or sell services for >>> just about anything Open Source. >>> http://p.sf.net/sfu/Xq1LFB >>> _______________________________________________ >>> json-lib-user mailing list >>> jso...@li... >>> https://lists.sourceforge.net/lists/listinfo/json-lib-user >>> >>> >> >> >> -- >> +++++++++++++++++++++++++++++++++++++++ >> morganpackard.com >> myspace.com/morganpackard >> finediving.org >> anticipaterecordings.com >> (646) 206-8337 >> > > > > -- > +++++++++++++++++++++++++++++++++++++++ > morganpackard.com > myspace.com/morganpackard > finediving.org > anticipaterecordings.com > (646) 206-8337 > -- Thomas Williams Java Programmer Dubit Limited +44 1133 947920 www.dubitlimited.com |