json-lib-user Mailing List for Json-lib (Page 8)
Brought to you by:
aalmiray
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(6) |
Sep
(5) |
Oct
(1) |
Nov
(7) |
Dec
(5) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(4) |
Feb
(5) |
Mar
(1) |
Apr
|
May
(11) |
Jun
(3) |
Jul
(12) |
Aug
(4) |
Sep
(8) |
Oct
(11) |
Nov
(7) |
Dec
(30) |
2008 |
Jan
(11) |
Feb
(15) |
Mar
(8) |
Apr
|
May
(9) |
Jun
(21) |
Jul
(1) |
Aug
(4) |
Sep
(1) |
Oct
|
Nov
(3) |
Dec
(8) |
2009 |
Jan
(6) |
Feb
(1) |
Mar
(3) |
Apr
(5) |
May
(10) |
Jun
(3) |
Jul
(1) |
Aug
|
Sep
(4) |
Oct
(1) |
Nov
(1) |
Dec
(1) |
2010 |
Jan
|
Feb
(2) |
Mar
(2) |
Apr
(3) |
May
(5) |
Jun
(1) |
Jul
|
Aug
(4) |
Sep
|
Oct
(1) |
Nov
(4) |
Dec
|
2011 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(8) |
Dec
|
2012 |
Jan
|
Feb
|
Mar
(4) |
Apr
|
May
(1) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2014 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Andres A. <aal...@ya...> - 2007-12-10 20:15:26
|
Hmm that is really strange, CVS browse shows that pom.xml (1.49) has the updated groovy version. I'll double check it. A word of caution, though Groovy 1.5 is finally out it's pom is not ready on maven's repo (sad but true) so you'll have to download it from http://groovy.codehaus.org/Download and manually install it in your local repo for the time being. On your other question on setting an specific class of Set, I think it may be possible by setting the appropriate classMap entry if the Set is a property of a bean, but if the Set is nested within a List or another Set it may not be that simple. For the later case a morpher should be used in a second pass. The reason why Set was not supported is that json arrays do care about element order, whereas Sets do not (though TreeSet does) at least that is what Sun's docs say, I'll look at it tonight. Cheers, Andres ----- Original Message ---- From: Jonathan <jso...@ki...> To: jso...@li... Sent: Monday, December 10, 2007 12:03:52 PM Subject: Re: [json-lib-user] Problems building from cvs Andres Almiray wrote: > 1. I wasn't aware of this, I'll update it with the correct link once I'm > out of the current firewall, thanks for spotting it. Glad I could help in some way. > 2. yesterday I committed a fix to the pom.xml referencing groovy 1.5 > instead of 1.1-final-SNAPSHOT Just did another full checkout (just after 2pm in NY) and I'm still experiencing this problem. Looking at the pom.xml it does appear to still reference the old SNAPSHOT: <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>1.1-final-SNAPSHOT</version> <scope>compile</scope> <optional>true</optional> </dependency> > 3. Json-lib 2.2 may come out before the holidays (or sooner), I was > expecting the groovy release. Great news. Unfortunately, I need to launch a beta in the next few days so I'm going to try an hack a fix with the current codebase to hold me over until 2.2. Thanks, Jonathan. --- [This E-mail scanned for viruses by Declude EVA] ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping |
From: Jonathan <jso...@ki...> - 2007-12-10 20:04:25
|
Andres Almiray wrote: > 1. I wasn't aware of this, I'll update it with the correct link once I'm > out of the current firewall, thanks for spotting it. Glad I could help in some way. > 2. yesterday I committed a fix to the pom.xml referencing groovy 1.5 > instead of 1.1-final-SNAPSHOT Just did another full checkout (just after 2pm in NY) and I'm still experiencing this problem. Looking at the pom.xml it does appear to still reference the old SNAPSHOT: <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>1.1-final-SNAPSHOT</version> <scope>compile</scope> <optional>true</optional> </dependency> > 3. Json-lib 2.2 may come out before the holidays (or sooner), I was > expecting the groovy release. Great news. Unfortunately, I need to launch a beta in the next few days so I'm going to try an hack a fix with the current codebase to hold me over until 2.2. Thanks, Jonathan. --- [This E-mail scanned for viruses by Declude EVA] |
From: Andres A. <aal...@ya...> - 2007-12-10 19:32:48
|
Jonathan, 1. I wasn't aware of this, I'll update it with the correct link once I'm out of the current firewall, thanks for spotting it. 2. yesterday I committed a fix to the pom.xml referencing groovy 1.5 instead of 1.1-final-SNAPSHOT 3. Json-lib 2.2 may come out before the holidays (or sooner), I was expecting the groovy release. Cheers, Andres ----- Original Message ---- From: Jonathan <jso...@ki...> To: jso...@li... Sent: Monday, December 10, 2007 9:05:05 AM Subject: [json-lib-user] Problems building from cvs 1. Currently, the link on the json-lib "Building instructions" page: http://json-lib.sourceforge.net/package.html which points to cvs page, below, has instructions to download ezmorph, not json-lib: http://sourceforge.net/cvs/?group_id=174866 I was able to successfully download the source using the following: cvs -d:pserver:ano...@js...:/cvsroot/json-lib login cvs -z3 -d:pserver:ano...@js...:/cvsroot/json-lib co -P json-lib 2. Typing "ant" at the root yields the following error: *** Begin Error *** Buildfile: build.xml [artifact:dependencies] An error has occurred while processing the Maven artifact tasks. [artifact:dependencies] Diagnosis: [artifact:dependencies] [artifact:dependencies] Unable to resolve artifact: required artifacts missing: [artifact:dependencies] org.codehaus.groovy:groovy-all:jar:1.1-final-SNAPSHOT [artifact:dependencies] [artifact:dependencies] for the artifact: [artifact:dependencies] net.sf.json-lib:json-lib:jar:2.2-SNAPSHOT [artifact:dependencies] [artifact:dependencies] from the specified remote repositories: [artifact:dependencies] central (http://repo1.maven.org/maven2) [artifact:dependencies] BUILD FAILED /home/jgordon/downloads/json-lib/build.xml:25: Unable to resolve artifact: required artifacts missing: org.codehaus.groovy:groovy-all:jar:1.1-final-SNAPSHOT for the artifact: net.sf.json-lib:json-lib:jar:2.2-SNAPSHOT from the specified remote repositories: central (http://repo1.maven.org/maven2) Total time: 1 second *** End Error *** I'd like to be able to build the project so I can do a quick and dirty fix until 2.2 is released. I'm not too familiar with maven. How can I get around this issue? 3. Any notion of when you expect 2.2 to come out? Thanks! Jonathan. --- [This E-mail scanned for viruses by Declude EVA] ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ json-lib-user mailing list jso...@li... https://lists.sourceforge.net/lists/listinfo/json-lib-user ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs |
From: Jonathan <jso...@ki...> - 2007-12-10 17:05:53
|
1. Currently, the link on the json-lib "Building instructions" page: http://json-lib.sourceforge.net/package.html which points to cvs page, below, has instructions to download ezmorph, not json-lib: http://sourceforge.net/cvs/?group_id=174866 I was able to successfully download the source using the following: cvs -d:pserver:ano...@js...:/cvsroot/json-lib login cvs -z3 -d:pserver:ano...@js...:/cvsroot/json-lib co -P json-lib 2. Typing "ant" at the root yields the following error: *** Begin Error *** Buildfile: build.xml [artifact:dependencies] An error has occurred while processing the Maven artifact tasks. [artifact:dependencies] Diagnosis: [artifact:dependencies] [artifact:dependencies] Unable to resolve artifact: required artifacts missing: [artifact:dependencies] org.codehaus.groovy:groovy-all:jar:1.1-final-SNAPSHOT [artifact:dependencies] [artifact:dependencies] for the artifact: [artifact:dependencies] net.sf.json-lib:json-lib:jar:2.2-SNAPSHOT [artifact:dependencies] [artifact:dependencies] from the specified remote repositories: [artifact:dependencies] central (http://repo1.maven.org/maven2) [artifact:dependencies] BUILD FAILED /home/jgordon/downloads/json-lib/build.xml:25: Unable to resolve artifact: required artifacts missing: org.codehaus.groovy:groovy-all:jar:1.1-final-SNAPSHOT for the artifact: net.sf.json-lib:json-lib:jar:2.2-SNAPSHOT from the specified remote repositories: central (http://repo1.maven.org/maven2) Total time: 1 second *** End Error *** I'd like to be able to build the project so I can do a quick and dirty fix until 2.2 is released. I'm not too familiar with maven. How can I get around this issue? 3. Any notion of when you expect 2.2 to come out? Thanks! Jonathan. --- [This E-mail scanned for viruses by Declude EVA] |
From: Andres A. <aal...@ya...> - 2007-12-10 01:19:12
|
FYI, I've added a discard() method to JSONArray/JSONObject that allows chaining as element() and accumulate() do. Cheers, Andres ----- Original Message ---- From: Haritha Juturu <har...@ya...> To: jso...@li... Sent: Thursday, December 6, 2007 4:22:22 PM Subject: [json-lib-user] Remove name value pair from JSONObject Hi Everyone, I am using JSON-LIB to serialize json to java objects. I have a java object ImageBean.When i do a JSONObject.fromObject( imgBean ) the output is {"sizeWidth":940,"style":"width:940px;","name":"","css":""} I am trying to remove width:940px name-value pair from this JSONObject by using this code snippet JSONObject.fromObject( imgBean ).remove("width"); When i print the JSONObject invoking remove() i get "940px" as the output. Is there a way to remove a name-value pair from the JSONObject and get the final output as {"sizeWidth":940,"name":"","css":""} Cheers Haritha 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 |
From: Andres A. <aal...@ya...> - 2007-12-09 03:45:06
|
I believe Json-lib doesn't support Sets as it should (at least Lists are covered), please raise an issue on the issue tracker. Cheers, Andres ----- Original Message ---- From: Jonathan <jso...@ki...> To: jso...@li... Sent: Saturday, December 8, 2007 7:39:11 PM Subject: [json-lib-user] Using toBean with a targetBean that has a property of class Set I have a class (BeanA) that has getters/setters for a java.util.Set (itemsB). I have no problem using JSONObject.fromObject to get a JSONObject. However, if I want to create an instance of the class by using JSONObject.toBean I receive the error: "beanClass is an interface. interface java.util.Set" Is there a way I can I tell json-lib the specific Set implementation I'd like it to use? Thanks! --- [This E-mail scanned for viruses by Declude EVA] ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ json-lib-user mailing list jso...@li... https://lists.sourceforge.net/lists/listinfo/json-lib-user ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping |
From: Andres A. <aal...@ya...> - 2007-12-09 03:43:48
|
Json-lib has the option of transforming JSONObject/JSONArray directly into = an specific class without DynaBeans in the middle.=0AYou just have to confi= gure a rootClass and optionally a classMap with jsonConfig to get it done. = I'm preparing more examples that=0Awill be available at the site when the n= ext release is ready (2.2), in the meantime you may inspect the test source= s to get an idea on how this feature works.=0A=0ACheers,=0AAndres=0A=0A=0A-= ---- Original Message ----=0AFrom: Haritha Juturu <har...@ya...= >=0ATo: jso...@li...=0ASent: Friday, December 7, 200= 7 12:08:28 PM=0ASubject: [json-lib-user] Using JSON -LIB for JSON to Java S= erialization=0A=0A=0AHi All,=0AI have a complicated JSON string which i am = trying to serialize to Java Objects using the Json-Lib library.=0AI thought= i will post a code snippet here to know if i am doing the right thing or t= heres a simpler way to serialize json to java.=0ACalling JSONObject.toBean(= ) returns a bunch of MorphDynaBeans which i morph to the objects in my appl= ication using EZMorph library.=0APlease have a look and send in your commen= ts.=0A=0AThis is my JSON string=0A{=0A"name":"Nameless=0A One",=0A"pages":[= =0A{"name":"Page1",=0A"canvas":"{"objectType":"EditorCanvas",=0A"id":"edito= rCanvas",=0A"name":"",=0A"sizeWidth":940,=0A"cssClass":"",=0A"style":"width= :940px;",=0A"children":[=0A{"objectType":"TextObject",=0A"id":"Text_1196907= 790312",=0A"name":"",=0A"cssClass":"",=0A"style":"left:40px;top:60px;width:= 620px;height:100px;",=0A"text":""[Winning the Nobel Peace Prize] ." =97Moha= mmad Yunus"},=0A{"objectType":"ImageObject",=0A"id":"Image_1196907800312",= =0A"name":"",=0A"position":({left:40, top:220}),=0A"size":({width:300, heig= ht:300}),=0A"cssClass":"",=0A"style":"left:40px;top:220px;width:300px;heigh= t:300px;",=0A}=0A]=0A}"=0A}=0A]=0A}=0A=0AJSON json =3D JSONSerializer.toJSO= N(jsonStr);=0A=0AMorpherRegistry morpherRegistry =3D new MorpherRegistry();= =0AmorpherRegistry.registerMorpher( new BeanMorpher( BaseObject.class,morph= erRegistry));=0AmorpherRegistry.registerMorpher( new BeanMorpher(SplashNote= Object.class,=0A morpherRegistry));=0AmorpherRegistry.registerMorpher( new = BeanMorpher( PageObject.class,morpherRegistry));=0AmorpherRegistry.register= Morpher( new BeanMorpher(EditorCanvas.class, morpherRegistry));=0A=0ASplash= NoteObject snObject =3D (SplashNoteObject) JSONObject.toBean((JSONObject) j= son, SplashNoteObject.class );=0APageObject page =3D(PageObject)morpherRegi= stry.morph(PageObject.class,snObject.getPages().get(0));=0A=0AEditorCanvas = bean =3D (EditorCanvas)page.getCanvas();=0A=0Ai havent included the code fo= r any further levels like TextObject and ImageObject=0A=0AIs this the only = was i can serialize json to java for java objects which have other java obj= ects in them. Do i need=0Ato morph the objects at every level to the bean i= need.=0A=0ACheers=0AHaritha=0A=0A=0A=0A=0A=0A Never miss a thing. M= ake Yahoo your homepage.=0A=0A=0A=0A=0A=0A=0A=0A _____________________= _______________________________________________________________=0ANever mis= s a thing. Make Yahoo your home page. =0Ahttp://www.yahoo.com/r/hs |
From: Jonathan <jso...@ki...> - 2007-12-09 03:39:50
|
I have a class (BeanA) that has getters/setters for a java.util.Set (itemsB). I have no problem using JSONObject.fromObject to get a JSONObject. However, if I want to create an instance of the class by using JSONObject.toBean I receive the error: "beanClass is an interface. interface java.util.Set" Is there a way I can I tell json-lib the specific Set implementation I'd like it to use? Thanks! --- [This E-mail scanned for viruses by Declude EVA] |
From: Haritha J. <har...@ya...> - 2007-12-07 20:08:42
|
Hi All,=0AI have a complicated JSON string which i am trying to serialize t= o Java Objects using the Json-Lib library.=0AI thought i will post a code s= nippet here to know if i am doing the right thing or theres a simpler way t= o serialize json to java.=0ACalling JSONObject.toBean() returns a bunch of = MorphDynaBeans which i morph to the objects in my application using EZMorph= library.=0APlease have a look and send in your comments.=0A=0AThis is my J= SON string=0A{=0A"name":"Nameless One",=0A"pages":[=0A{"name":"Page1",=0A"c= anvas":"{"objectType":"EditorCanvas",=0A"id":"editorCanvas",=0A"name":"",= =0A"sizeWidth":940,=0A"cssClass":"",=0A"style":"width:940px;",=0A"children"= :[=0A{"objectType":"TextObject",=0A"id":"Text_1196907790312",=0A"name":"",= =0A"cssClass":"",=0A"style":"left:40px;top:60px;width:620px;height:100px;",= =0A"text":""[Winning the Nobel Peace Prize] ." =97Mohammad Yunus"},=0A{"obj= ectType":"ImageObject",=0A"id":"Image_1196907800312",=0A"name":"",=0A"posit= ion":({left:40, top:220}),=0A"size":({width:300, height:300}),=0A"cssClass"= :"",=0A"style":"left:40px;top:220px;width:300px;height:300px;",=0A}=0A]=0A}= "=0A}=0A]=0A}=0A=0AJSON json =3D JSONSerializer.toJSON(jsonStr);=0A=0AMorph= erRegistry morpherRegistry =3D new MorpherRegistry();=0AmorpherRegistry.reg= isterMorpher( new BeanMorpher( BaseObject.class,morpherRegistry));=0Amorphe= rRegistry.registerMorpher( new BeanMorpher(SplashNoteObject.class, morpherR= egistry));=0AmorpherRegistry.registerMorpher( new BeanMorpher( PageObject.c= lass,morpherRegistry));=0AmorpherRegistry.registerMorpher( new BeanMorpher(= EditorCanvas.class, morpherRegistry));=0A=0ASplashNoteObject snObject =3D (= SplashNoteObject) JSONObject.toBean((JSONObject) json, SplashNoteObject.cla= ss );=0APageObject page =3D(PageObject)morpherRegistry.morph(PageObject.cla= ss,snObject.getPages().get(0));=0A=0AEditorCanvas bean =3D (EditorCanvas)pa= ge.getCanvas();=0A=0Ai havent included the code for any further levels like= TextObject and ImageObject=0A=0AIs this the only was i can serialize json = to java for java objects which have other java objects in them. Do i need= =0Ato morph the objects at every level to the bean i need.=0A=0ACheers=0AHa= ritha=0A=0A=0A=0A=0A _________________________________________________= ___________________________________=0ANever miss a thing. Make Yahoo your = home page. =0Ahttp://www.yahoo.com/r/hs |
From: Haritha J. <har...@ya...> - 2007-12-07 19:57:35
|
Thanks Andres , setting exclusions on JsonConfig object worked out for me . ----- Original Message ---- From: Andres Almiray <aal...@ya...> To: Haritha Juturu <har...@ya...>; jso...@li... Sent: Thursday, December 6, 2007 4:32:01 PM Subject: Re: [json-lib-user] Remove name value pair from JSONObject If I understand your json correctly you have the following { "sizewidth" : 940, "style" : "width:940px;", "name" : "", "css" : "" } so you'll have to call JSONObject jsonObject = JSONObject.fromObject( imgBean ); jsonObject.remove( "style" ); because remove() returns the removed value, not the instance of a JSONObject where it was invoked, meaning you can't chain remove the same way as you can chain element or accumulate, reason being is that remove comes from the Map interface. Perhaps the addition of a chained remove-like method is in order. Another way to solve your problem is to use property exclusions JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setExclusions( new String[ ] { "style" } ); JSONObject jsonObject = JSONObject.fromObject( imgBean, jsonConfig ); assertFalse( jsonObject.has("style") ) Cheers, Andres ----- Original Message ---- From: Haritha Juturu <har...@ya...> To: jso...@li... Sent: Thursday, December 6, 2007 4:22:22 PM Subject: [json-lib-user] Remove name value pair from JSONObject Hi Everyone, I am using JSON-LIB to serialize json to java objects. I have a java object ImageBean.When i do a JSONObject.fromObject( imgBean ) the output is {"sizeWidth":940,"style":"width:940px;","name":"","css":""} I am trying to remove width:940px name-value pair from this JSONObject by using this code snippet JSONObject.fromObject( imgBean ).remove("width"); When i print the JSONObject invoking remove() i get "940px" as the output. Is there a way to remove a name-value pair from the JSONObject and get the final output as {"sizeWidth":940,"name":"","css":""} Cheers Haritha Looking for last minute shopping deals? Find them fast with Yahoo! Search. 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 |
From: Andres A. <aal...@ya...> - 2007-12-07 00:38:51
|
No, Json-lib will not transform a key. It assumes you are using Strings or String-friendly objects as keys, a Map as key would result in a weird key. Map map = new HashMap(); map.put("key","value"); Map tree = new HashMap(); tree.put( map, "another value" ) JSONObject json = JSONObject.fromObject( tree ) System.out.println( json.toString(2) ) ----------------- { "{key=value}" : "another value" } Cheers, Andres ----- Original Message ---- From: Cristian Maluenda <cma...@gm...> To: jso...@li... Sent: Thursday, December 6, 2007 3:51:39 PM Subject: [json-lib-user] Json Tree Hi. Can Json-lib convert from a Map to Json, Where the Map Key is another Map?. I have to transform a Tree to Json, and I using Maps. Regards, Cristian. ------------------------------------------------------------------------- SF.Net email is sponsored by: Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ json-lib-user mailing list jso...@li... https://lists.sourceforge.net/lists/listinfo/json-lib-user ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs |
From: Andres A. <aal...@ya...> - 2007-12-07 00:32:08
|
If I understand your json correctly you have the following { "sizewidth" : 940, "style" : "width:940px;", "name" : "", "css" : "" } so you'll have to call JSONObject jsonObject = JSONObject.fromObject( imgBean ); jsonObject.remove( "style" ); because remove() returns the removed value, not the instance of a JSONObject where it was invoked, meaning you can't chain remove the same way as you can chain element or accumulate, reason being is that remove comes from the Map interface. Perhaps the addition of a chained remove-like method is in order. Another way to solve your problem is to use property exclusions JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setExclusions( new String[ ] { "style" } ); JSONObject jsonObject = JSONObject.fromObject( imgBean, jsonConfig ); assertFalse( jsonObject.has("style") ) Cheers, Andres ----- Original Message ---- From: Haritha Juturu <har...@ya...> To: jso...@li... Sent: Thursday, December 6, 2007 4:22:22 PM Subject: [json-lib-user] Remove name value pair from JSONObject Hi Everyone, I am using JSON-LIB to serialize json to java objects. I have a java object ImageBean.When i do a JSONObject.fromObject( imgBean ) the output is {"sizeWidth":940,"style":"width:940px;","name":"","css":""} I am trying to remove width:940px name-value pair from this JSONObject by using this code snippet JSONObject.fromObject( imgBean ).remove("width"); When i print the JSONObject invoking remove() i get "940px" as the output. Is there a way to remove a name-value pair from the JSONObject and get the final output as {"sizeWidth":940,"name":"","css":""} Cheers Haritha Looking for last minute shopping deals? Find them fast with Yahoo! Search. ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping |
From: Haritha J. <har...@ya...> - 2007-12-07 00:22:33
|
Hi Everyone, I am using JSON-LIB to serialize json to java objects. I have a java object ImageBean.When i do a JSONObject.fromObject( imgBean ) the output is {"sizeWidth":940,"style":"width:940px;","name":"","css":""} I am trying to remove width:940px name-value pair from this JSONObject by using this code snippet JSONObject.fromObject( imgBean ).remove("width"); When i print the JSONObject invoking remove() i get "940px" as the output. Is there a way to remove a name-value pair from the JSONObject and get the final output as {"sizeWidth":940,"name":"","css":""} Cheers Haritha ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |
From: Cristian M. <cma...@gm...> - 2007-12-06 23:51:45
|
Hi. Can Json-lib convert from a Map to Json, Where the Map Key is another Map?. I have to transform a Tree to Json, and I using Maps. Regards, Cristian. |
From: John C. <Joh...@no...> - 2007-12-06 17:32:28
|
Strangely, I found that whitespace seems to trigger the anomalous behavior. If I remove all whitespace between elements, the FEATURES element re-appears in the JSON representation regardless of how many FEATURE children there are. --john Andres Almiray wrote: > Then it is as I suspected, that the serializer thinks FEATURES should > be treated as an array rather than as an object, which is strange as > in the first example you can clearly see 3 named elements on FEATURES. > I'll check it tonight and let you know what I found. > > Cheers, > Andres > > > ----- Original Message ---- > From: John Cartwright <Joh...@no...> > To: Andres Almiray <aal...@ya...> > Cc: jso...@li... > Sent: Wednesday, December 5, 2007 4:01:16 PM > Subject: Re: [json-lib-user] XML -> JSON, "type" attribute omitted? > > Thanks for the prompt reply! This is a version that I compiled from CVS > that includes the fix you made on 10/14: > > > It wasn't that difficult after all, the fix is already on the cvs, > > here is the link to the FR > > > http://sourceforge.net/tracker/index.php?func=detail&aid=1813520&group_id=171425&atid=857931 > <http://sourceforge.net/tracker/index.php?func=detail&aid=1813520&group_id=171425&atid=857931> > > > > <http://sourceforge.net/tracker/index.php?func=detail&aid=1813520&group_id=171425&atid=857931 > <http://sourceforge.net/tracker/index.php?func=detail&aid=1813520&group_id=171425&atid=857931>> > > I confirmed that it doesn't have to do w/ the element name itself. It > does however seem to be related to the number of FEATURE elements. The > following is the XML/JSON result produced when FEATURES includes > multiple FEATURE children: > > <?xml version="1.0" encoding="UTF-8"?> > <ARCXML version="1.1"> > <RESPONSE> > <FEATURES> > <FEATURE> > <ENVELOPE minx="-81.5650024414062" miny="23.0499992370605" > maxx="-81.5650024414062" maxy="23.0499992370605"/> > <FIELDS> > <FIELD name="CITY_NAME" value="Matanzas" /> > <FIELD name="GMI_ADMIN" value="CUB-MTN" /> > <FIELD name="ADMIN_NAME" value="Matanzas" /> > </FIELDS> > </FEATURE> > <FEATURE> > <ENVELOPE minx="-82.4164505004883" miny="23.0489521026611" > maxx="-82.4164505004883" maxy="23.0489521026611"/> > <FIELDS> > <FIELD name="CITY_NAME" value="Havana" /> > <FIELD name="GMI_ADMIN" value="CUB-CHB" /> > <FIELD name="ADMIN_NAME" value="Ciudad de la Habana" /> > </FIELDS> > </FEATURE> > <FEATURECOUNT count="14" hasmore="false" /> > </FEATURES> > </RESPONSE> > </ARCXML> > > {"RESPONSE":{"FEATURES":{"FEATURECOUNT":{"@hasmore":"false","@count":"14"},"FEATURE":[{"ENVELOPE":{"@minx":"-81.5650024414062","@maxy":"23.0499992370605","@maxx":"-81.5650024414062","@miny":"23.0499992370605"},"FIELDS":[{"@value":"Matanzas","@name":"CITY_NAME"},{"@value":"CUB-MTN","@name":"GMI_ADMIN"},{"@value":"Matanzas","@name":"ADMIN_NAME"}]},{"ENVELOPE":{"@minx":"-82.4164505004883","@maxx":"-82.4164505004883","@maxy":"23.0489521026611","@miny":"23.0489521026611"},"FIELDS":[{"@value":"Havana","@name":"CITY_NAME"},{"@value":"CUB-CHB","@name":"GMI_ADMIN"},{"@value":"Ciudad > > de la Habana","@name":"ADMIN_NAME"}]}]}},"@version":"1.1"} > > > -- john > > Andres Almiray wrote: > > Hi John, > > > > No, in this case seems to be something else, perhaps corner case where > > XMLSerializer can't decide if FEATURES should be a JSONObject instead > > of a JSONArray. To me it should be something like > > > > { > > RESPONSE: > > { > > FEATURES: > > { > > ... > > } > > } > > } > > > > Are you getting this result with Json-lib 2.1 ? > > > > -- Andres > > > > ----- Original Message ---- > > From: John Cartwright <Joh...@no... > <mailto:Joh...@no...>> > > To: Andres Almiray <aal...@ya... <mailto:aal...@ya...>> > > Cc: jso...@li... > <mailto:jso...@li...> > > Sent: Wednesday, December 5, 2007 3:42:47 PM > > Subject: Re: [json-lib-user] XML -> JSON, "type" attribute omitted? > > > > Hi Andres, > > > > is it possible that an XML element named features would have the same > > trouble? I'm finding the XML listed below is serializing to JSON w/o > > that element. > > > > Thanks! > > > > -- john > > > > <?xml version="1.0" encoding="UTF-8"?> > > <ARCXML version="1.1"> > > <RESPONSE> > > <FEATURES> > > <FEATURE> > > <ENVELOPE minx="-178.216552734375" miny="18.9254779815674" > > maxx="179.775939941406" maxy="71.3514404296875"/> > > <FIELDS> > > <FIELD name="FIPS_CNTRY" value="US" /> > > <FIELD name="GMI_CNTRY" value="USA" /> > > <FIELD name="ISO_2DIGIT" value="US" /> > > <FIELD name="ISO_3DIGIT" value="USA" /> > > <FIELD name="CNTRY_NAME" value="United States" /> > > <FIELD name="LONG_NAME" value="United States" /> > > <FIELD name="SOVEREIGN" value="United States" /> > > <FIELD name="POP_CNTRY" value="258833000" /> > > <FIELD name="CURR_TYPE" value="US Dollar" /> > > <FIELD name="CURR_CODE" value="USD" /> > > <FIELD name="LANDLOCKED" value="N" /> > > <FIELD name="SQKM" value="9449365" /> > > <FIELD name="SQMI" value="3648399.75" /> > > <FIELD name="COLORMAP" value="5" /> > > <FIELD name="#SHAPE#" value="[Geometry]" /> > > <FIELD name="#ID#" value="234" /> > > </FIELDS> > > </FEATURE> > > <FEATURECOUNT count="1" hasmore="false" /> > > <ENVELOPE minx="-178.216552734375" miny="18.9254779815674" > > maxx="179.775939941406" maxy="71.3514404296875"/> > > </FEATURES> > > </RESPONSE> > > </ARCXML> > > > > > {"RESPONSE":[{"ENVELOPE":{"@miny":"18.9254779815674","@minx":"-178.216552734375","@maxy":"71.3514404296875","@maxx":"179.775939941406"},"FEATURECOUNT":{"@hasmore":"false","@count":"1"},"FEATURE":{"ENVELOPE":{"@miny":"18.9254779815674","@minx":"-178.216552734375","@maxy":"71.3514404296875","@maxx":"179.775939941406"},"FIELDS":[{"@name":"FIPS_CNTRY","@value":"US"},{"@name":"GMI_CNTRY","@value":"USA"},{"@name":"ISO_2DIGIT","@value":"US"},{"@name":"ISO_3DIGIT","@value":"USA"},{"@name":"CNTRY_NAME","@value":"United > > > > > States"},{"@name":"LONG_NAME","@value":"United > > States"},{"@name":"SOVEREIGN","@value":"United > > > States"},{"@name":"POP_CNTRY","@value":"258833000"},{"@name":"CURR_TYPE","@value":"US > > > > > > Dollar"},{"@name":"CURR_CODE","@value":"USD"},{"@name":"LANDLOCKED","@value":"N"},{"@name":"SQKM","@value":"9449365"},{"@name":"SQMI","@value":"3648399.75"},{"@name":"COLORMAP","@value":"5"},{"@name":"#SHAPE#","@value":"[Geometry]"},{"@name":"#ID#","@value":"234"}]}}],"@version":"1.1"} > > > > > > Andres Almiray wrote: > > > Hi John, > > > > > > Sorry for the late reply. The answer is yes and no, let me explain. > > > XMLSerializer has an option to expose a value's type when serializing > > > JSON to XML, that information is written as an attribute named 'type'. > > > When reading it is assumed you want to recover that information if > > > 'type' is an attribute of a node, but it seems that in your case type > > > has a business meaning and should be treated like that instead of a > > > construct of the library. The same will happen with an attributed > > > named 'class' by the way. > > > > > > Let me look for an alternative that is backward compatible at the same > > > time. > > > > > > Cheers, > > > Andres > > > > > > ------------------------------------------- > > > http://jroller.com/page/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: John Cartwright <Joh...@no... > <mailto:Joh...@no...> > > <mailto:Joh...@no... <mailto:Joh...@no...>>> > > > To: jso...@li... > <mailto:jso...@li...> > > <mailto:jso...@li... > <mailto:jso...@li...>> > > > Sent: Monday, October 8, 2007 10:29:37 AM > > > Subject: [json-lib-user] XML -> JSON, "type" attribute omitted? > > > > > > Hello All, > > > > > > It seems to me that when converting XML to JSON, elements w/ an > > > attribute named "type" have that attribute omitted. Is this expected > > > behavior? > > > > > > Thanks! > > > > > > -- john > > > > > > > > > > > > ------------------------------------------------------------------------- > > > This SF.net <http://SF.net> <http://SF.net> email is sponsored by: > Splunk Inc. > > > Still grepping through log files to find problems? Stop. > > > Now Search log events and configuration files using AJAX and a > browser. > > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > > _______________________________________________ > > > json-lib-user mailing list > > > jso...@li... > <mailto:jso...@li...> > > <mailto:jso...@li... > <mailto:jso...@li...>> > > > https://lists.sourceforge.net/lists/listinfo/json-lib-user > > > > > > > > > > ------------------------------------------------------------------------ > > > Catch up on fall's hot new shows > > > > > > <http://us.rd.yahoo.com/tv/mail/tagline/falltv/evt=47093/*http://tv.yahoo.com/collections/3658%20> > > > > > > on Yahoo! TV. Watch previews, get listings, and more! > > > > > > ------------------------------------------------------------------------ > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try > > it now. > > > <http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ%20> > > > ------------------------------------------------------------------------ > Never miss a thing. Make Yahoo your homepage. > <http://us.rd.yahoo.com/evt=51438/*http://www.yahoo.com/r/hs> |
From: Andres A. <aal...@ya...> - 2007-12-06 00:08:13
|
Then it is as I suspected, that the serializer thinks FEATURES should be treated as an array rather than as an object, which is strange as in the first example you can clearly see 3 named elements on FEATURES. I'll check it tonight and let you know what I found. Cheers, Andres ----- Original Message ---- From: John Cartwright <Joh...@no...> To: Andres Almiray <aal...@ya...> Cc: jso...@li... Sent: Wednesday, December 5, 2007 4:01:16 PM Subject: Re: [json-lib-user] XML -> JSON, "type" attribute omitted? Thanks for the prompt reply! This is a version that I compiled from CVS that includes the fix you made on 10/14: > It wasn't that difficult after all, the fix is already on the cvs, > here is the link to the FR > http://sourceforge.net/tracker/index.php?func=detail&aid=1813520&group_id=171425&atid=857931 > <http://sourceforge.net/tracker/index.php?func=detail&aid=1813520&group_id=171425&atid=857931> I confirmed that it doesn't have to do w/ the element name itself. It does however seem to be related to the number of FEATURE elements. The following is the XML/JSON result produced when FEATURES includes multiple FEATURE children: <?xml version="1.0" encoding="UTF-8"?> <ARCXML version="1.1"> <RESPONSE> <FEATURES> <FEATURE> <ENVELOPE minx="-81.5650024414062" miny="23.0499992370605" maxx="-81.5650024414062" maxy="23.0499992370605"/> <FIELDS> <FIELD name="CITY_NAME" value="Matanzas" /> <FIELD name="GMI_ADMIN" value="CUB-MTN" /> <FIELD name="ADMIN_NAME" value="Matanzas" /> </FIELDS> </FEATURE> <FEATURE> <ENVELOPE minx="-82.4164505004883" miny="23.0489521026611" maxx="-82.4164505004883" maxy="23.0489521026611"/> <FIELDS> <FIELD name="CITY_NAME" value="Havana" /> <FIELD name="GMI_ADMIN" value="CUB-CHB" /> <FIELD name="ADMIN_NAME" value="Ciudad de la Habana" /> </FIELDS> </FEATURE> <FEATURECOUNT count="14" hasmore="false" /> </FEATURES> </RESPONSE> </ARCXML> {"RESPONSE":{"FEATURES":{"FEATURECOUNT":{"@hasmore":"false","@count":"14"},"FEATURE":[{"ENVELOPE":{"@minx":"-81.5650024414062","@maxy":"23.0499992370605","@maxx":"-81.5650024414062","@miny":"23.0499992370605"},"FIELDS":[{"@value":"Matanzas","@name":"CITY_NAME"},{"@value":"CUB-MTN","@name":"GMI_ADMIN"},{"@value":"Matanzas","@name":"ADMIN_NAME"}]},{"ENVELOPE":{"@minx":"-82.4164505004883","@maxx":"-82.4164505004883","@maxy":"23.0489521026611","@miny":"23.0489521026611"},"FIELDS":[{"@value":"Havana","@name":"CITY_NAME"},{"@value":"CUB-CHB","@name":"GMI_ADMIN"},{"@value":"Ciudad de la Habana","@name":"ADMIN_NAME"}]}]}},"@version":"1.1"} -- john Andres Almiray wrote: > Hi John, > > No, in this case seems to be something else, perhaps corner case where > XMLSerializer can't decide if FEATURES should be a JSONObject instead > of a JSONArray. To me it should be something like > > { > RESPONSE: > { > FEATURES: > { > ... > } > } > } > > Are you getting this result with Json-lib 2.1 ? > > -- Andres > > ----- Original Message ---- > From: John Cartwright <Joh...@no...> > To: Andres Almiray <aal...@ya...> > Cc: jso...@li... > Sent: Wednesday, December 5, 2007 3:42:47 PM > Subject: Re: [json-lib-user] XML -> JSON, "type" attribute omitted? > > Hi Andres, > > is it possible that an XML element named features would have the same > trouble? I'm finding the XML listed below is serializing to JSON w/o > that element. > > Thanks! > > -- john > > <?xml version="1.0" encoding="UTF-8"?> > <ARCXML version="1.1"> > <RESPONSE> > <FEATURES> > <FEATURE> > <ENVELOPE minx="-178.216552734375" miny="18.9254779815674" > maxx="179.775939941406" maxy="71.3514404296875"/> > <FIELDS> > <FIELD name="FIPS_CNTRY" value="US" /> > <FIELD name="GMI_CNTRY" value="USA" /> > <FIELD name="ISO_2DIGIT" value="US" /> > <FIELD name="ISO_3DIGIT" value="USA" /> > <FIELD name="CNTRY_NAME" value="United States" /> > <FIELD name="LONG_NAME" value="United States" /> > <FIELD name="SOVEREIGN" value="United States" /> > <FIELD name="POP_CNTRY" value="258833000" /> > <FIELD name="CURR_TYPE" value="US Dollar" /> > <FIELD name="CURR_CODE" value="USD" /> > <FIELD name="LANDLOCKED" value="N" /> > <FIELD name="SQKM" value="9449365" /> > <FIELD name="SQMI" value="3648399.75" /> > <FIELD name="COLORMAP" value="5" /> > <FIELD name="#SHAPE#" value="[Geometry]" /> > <FIELD name="#ID#" value="234" /> > </FIELDS> > </FEATURE> > <FEATURECOUNT count="1" hasmore="false" /> > <ENVELOPE minx="-178.216552734375" miny="18.9254779815674" > maxx="179.775939941406" maxy="71.3514404296875"/> > </FEATURES> > </RESPONSE> > </ARCXML> > > {"RESPONSE":[{"ENVELOPE":{"@miny":"18.9254779815674","@minx":"-178.216552734375","@maxy":"71.3514404296875","@maxx":"179.775939941406"},"FEATURECOUNT":{"@hasmore":"false","@count":"1"},"FEATURE":{"ENVELOPE":{"@miny":"18.9254779815674","@minx":"-178.216552734375","@maxy":"71.3514404296875","@maxx":"179.775939941406"},"FIELDS":[{"@name":"FIPS_CNTRY","@value":"US"},{"@name":"GMI_CNTRY","@value":"USA"},{"@name":"ISO_2DIGIT","@value":"US"},{"@name":"ISO_3DIGIT","@value":"USA"},{"@name":"CNTRY_NAME","@value":"United > > States"},{"@name":"LONG_NAME","@value":"United > States"},{"@name":"SOVEREIGN","@value":"United > States"},{"@name":"POP_CNTRY","@value":"258833000"},{"@name":"CURR_TYPE","@value":"US > > Dollar"},{"@name":"CURR_CODE","@value":"USD"},{"@name":"LANDLOCKED","@value":"N"},{"@name":"SQKM","@value":"9449365"},{"@name":"SQMI","@value":"3648399.75"},{"@name":"COLORMAP","@value":"5"},{"@name":"#SHAPE#","@value":"[Geometry]"},{"@name":"#ID#","@value":"234"}]}}],"@version":"1.1"} > > > Andres Almiray wrote: > > Hi John, > > > > Sorry for the late reply. The answer is yes and no, let me explain. > > XMLSerializer has an option to expose a value's type when serializing > > JSON to XML, that information is written as an attribute named 'type'. > > When reading it is assumed you want to recover that information if > > 'type' is an attribute of a node, but it seems that in your case type > > has a business meaning and should be treated like that instead of a > > construct of the library. The same will happen with an attributed > > named 'class' by the way. > > > > Let me look for an alternative that is backward compatible at the same > > time. > > > > Cheers, > > Andres > > > > ------------------------------------------- > > http://jroller.com/page/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: John Cartwright <Joh...@no... > <mailto:Joh...@no...>> > > To: jso...@li... > <mailto:jso...@li...> > > Sent: Monday, October 8, 2007 10:29:37 AM > > Subject: [json-lib-user] XML -> JSON, "type" attribute omitted? > > > > Hello All, > > > > It seems to me that when converting XML to JSON, elements w/ an > > attribute named "type" have that attribute omitted. Is this expected > > behavior? > > > > Thanks! > > > > -- john > > > > > > > ------------------------------------------------------------------------- > > This SF.net <http://SF.net> email is sponsored by: Splunk Inc. > > Still grepping through log files to find problems? Stop. > > Now Search log events and configuration files using AJAX and a browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > _______________________________________________ > > json-lib-user mailing list > > jso...@li... > <mailto:jso...@li...> > > https://lists.sourceforge.net/lists/listinfo/json-lib-user > > > > > > ------------------------------------------------------------------------ > > Catch up on fall's hot new shows > > > <http://us.rd.yahoo.com/tv/mail/tagline/falltv/evt=47093/*http://tv.yahoo.com/collections/3658%20> > > > on Yahoo! TV. Watch previews, get listings, and more! > > > ------------------------------------------------------------------------ > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try > it now. > <http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ%20> ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |
From: John C. <Joh...@no...> - 2007-12-06 00:01:24
|
Thanks for the prompt reply! This is a version that I compiled from CVS that includes the fix you made on 10/14: > It wasn't that difficult after all, the fix is already on the cvs, > here is the link to the FR > http://sourceforge.net/tracker/index.php?func=detail&aid=1813520&group_id=171425&atid=857931 > <http://sourceforge.net/tracker/index.php?func=detail&aid=1813520&group_id=171425&atid=857931> I confirmed that it doesn't have to do w/ the element name itself. It does however seem to be related to the number of FEATURE elements. The following is the XML/JSON result produced when FEATURES includes multiple FEATURE children: <?xml version="1.0" encoding="UTF-8"?> <ARCXML version="1.1"> <RESPONSE> <FEATURES> <FEATURE> <ENVELOPE minx="-81.5650024414062" miny="23.0499992370605" maxx="-81.5650024414062" maxy="23.0499992370605"/> <FIELDS> <FIELD name="CITY_NAME" value="Matanzas" /> <FIELD name="GMI_ADMIN" value="CUB-MTN" /> <FIELD name="ADMIN_NAME" value="Matanzas" /> </FIELDS> </FEATURE> <FEATURE> <ENVELOPE minx="-82.4164505004883" miny="23.0489521026611" maxx="-82.4164505004883" maxy="23.0489521026611"/> <FIELDS> <FIELD name="CITY_NAME" value="Havana" /> <FIELD name="GMI_ADMIN" value="CUB-CHB" /> <FIELD name="ADMIN_NAME" value="Ciudad de la Habana" /> </FIELDS> </FEATURE> <FEATURECOUNT count="14" hasmore="false" /> </FEATURES> </RESPONSE> </ARCXML> {"RESPONSE":{"FEATURES":{"FEATURECOUNT":{"@hasmore":"false","@count":"14"},"FEATURE":[{"ENVELOPE":{"@minx":"-81.5650024414062","@maxy":"23.0499992370605","@maxx":"-81.5650024414062","@miny":"23.0499992370605"},"FIELDS":[{"@value":"Matanzas","@name":"CITY_NAME"},{"@value":"CUB-MTN","@name":"GMI_ADMIN"},{"@value":"Matanzas","@name":"ADMIN_NAME"}]},{"ENVELOPE":{"@minx":"-82.4164505004883","@maxx":"-82.4164505004883","@maxy":"23.0489521026611","@miny":"23.0489521026611"},"FIELDS":[{"@value":"Havana","@name":"CITY_NAME"},{"@value":"CUB-CHB","@name":"GMI_ADMIN"},{"@value":"Ciudad de la Habana","@name":"ADMIN_NAME"}]}]}},"@version":"1.1"} -- john Andres Almiray wrote: > Hi John, > > No, in this case seems to be something else, perhaps corner case where > XMLSerializer can't decide if FEATURES should be a JSONObject instead > of a JSONArray. To me it should be something like > > { > RESPONSE: > { > FEATURES: > { > ... > } > } > } > > Are you getting this result with Json-lib 2.1 ? > > -- Andres > > ----- Original Message ---- > From: John Cartwright <Joh...@no...> > To: Andres Almiray <aal...@ya...> > Cc: jso...@li... > Sent: Wednesday, December 5, 2007 3:42:47 PM > Subject: Re: [json-lib-user] XML -> JSON, "type" attribute omitted? > > Hi Andres, > > is it possible that an XML element named features would have the same > trouble? I'm finding the XML listed below is serializing to JSON w/o > that element. > > Thanks! > > -- john > > <?xml version="1.0" encoding="UTF-8"?> > <ARCXML version="1.1"> > <RESPONSE> > <FEATURES> > <FEATURE> > <ENVELOPE minx="-178.216552734375" miny="18.9254779815674" > maxx="179.775939941406" maxy="71.3514404296875"/> > <FIELDS> > <FIELD name="FIPS_CNTRY" value="US" /> > <FIELD name="GMI_CNTRY" value="USA" /> > <FIELD name="ISO_2DIGIT" value="US" /> > <FIELD name="ISO_3DIGIT" value="USA" /> > <FIELD name="CNTRY_NAME" value="United States" /> > <FIELD name="LONG_NAME" value="United States" /> > <FIELD name="SOVEREIGN" value="United States" /> > <FIELD name="POP_CNTRY" value="258833000" /> > <FIELD name="CURR_TYPE" value="US Dollar" /> > <FIELD name="CURR_CODE" value="USD" /> > <FIELD name="LANDLOCKED" value="N" /> > <FIELD name="SQKM" value="9449365" /> > <FIELD name="SQMI" value="3648399.75" /> > <FIELD name="COLORMAP" value="5" /> > <FIELD name="#SHAPE#" value="[Geometry]" /> > <FIELD name="#ID#" value="234" /> > </FIELDS> > </FEATURE> > <FEATURECOUNT count="1" hasmore="false" /> > <ENVELOPE minx="-178.216552734375" miny="18.9254779815674" > maxx="179.775939941406" maxy="71.3514404296875"/> > </FEATURES> > </RESPONSE> > </ARCXML> > > {"RESPONSE":[{"ENVELOPE":{"@miny":"18.9254779815674","@minx":"-178.216552734375","@maxy":"71.3514404296875","@maxx":"179.775939941406"},"FEATURECOUNT":{"@hasmore":"false","@count":"1"},"FEATURE":{"ENVELOPE":{"@miny":"18.9254779815674","@minx":"-178.216552734375","@maxy":"71.3514404296875","@maxx":"179.775939941406"},"FIELDS":[{"@name":"FIPS_CNTRY","@value":"US"},{"@name":"GMI_CNTRY","@value":"USA"},{"@name":"ISO_2DIGIT","@value":"US"},{"@name":"ISO_3DIGIT","@value":"USA"},{"@name":"CNTRY_NAME","@value":"United > > States"},{"@name":"LONG_NAME","@value":"United > States"},{"@name":"SOVEREIGN","@value":"United > States"},{"@name":"POP_CNTRY","@value":"258833000"},{"@name":"CURR_TYPE","@value":"US > > Dollar"},{"@name":"CURR_CODE","@value":"USD"},{"@name":"LANDLOCKED","@value":"N"},{"@name":"SQKM","@value":"9449365"},{"@name":"SQMI","@value":"3648399.75"},{"@name":"COLORMAP","@value":"5"},{"@name":"#SHAPE#","@value":"[Geometry]"},{"@name":"#ID#","@value":"234"}]}}],"@version":"1.1"} > > > Andres Almiray wrote: > > Hi John, > > > > Sorry for the late reply. The answer is yes and no, let me explain. > > XMLSerializer has an option to expose a value's type when serializing > > JSON to XML, that information is written as an attribute named 'type'. > > When reading it is assumed you want to recover that information if > > 'type' is an attribute of a node, but it seems that in your case type > > has a business meaning and should be treated like that instead of a > > construct of the library. The same will happen with an attributed > > named 'class' by the way. > > > > Let me look for an alternative that is backward compatible at the same > > time. > > > > Cheers, > > Andres > > > > ------------------------------------------- > > http://jroller.com/page/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: John Cartwright <Joh...@no... > <mailto:Joh...@no...>> > > To: jso...@li... > <mailto:jso...@li...> > > Sent: Monday, October 8, 2007 10:29:37 AM > > Subject: [json-lib-user] XML -> JSON, "type" attribute omitted? > > > > Hello All, > > > > It seems to me that when converting XML to JSON, elements w/ an > > attribute named "type" have that attribute omitted. Is this expected > > behavior? > > > > Thanks! > > > > -- john > > > > > > > ------------------------------------------------------------------------- > > This SF.net <http://SF.net> email is sponsored by: Splunk Inc. > > Still grepping through log files to find problems? Stop. > > Now Search log events and configuration files using AJAX and a browser. > > Download your FREE copy of Splunk now >> http://get.splunk.com/ > > _______________________________________________ > > json-lib-user mailing list > > jso...@li... > <mailto:jso...@li...> > > https://lists.sourceforge.net/lists/listinfo/json-lib-user > > > > > > ------------------------------------------------------------------------ > > Catch up on fall's hot new shows > > > <http://us.rd.yahoo.com/tv/mail/tagline/falltv/evt=47093/*http://tv.yahoo.com/collections/3658%20> > > > on Yahoo! TV. Watch previews, get listings, and more! > > > ------------------------------------------------------------------------ > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try > it now. > <http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ%20> |
From: Andres A. <aal...@ya...> - 2007-12-05 23:50:11
|
Hi John, No, in this case seems to be something else, perhaps corner case where XMLSerializer can't decide if FEATURES should be a JSONObject instead of a JSONArray. To me it should be something like { RESPONSE: { FEATURES: { ... } } } Are you getting this result with Json-lib 2.1 ? -- Andres ----- Original Message ---- From: John Cartwright <Joh...@no...> To: Andres Almiray <aal...@ya...> Cc: jso...@li... Sent: Wednesday, December 5, 2007 3:42:47 PM Subject: Re: [json-lib-user] XML -> JSON, "type" attribute omitted? Hi Andres, is it possible that an XML element named features would have the same trouble? I'm finding the XML listed below is serializing to JSON w/o that element. Thanks! -- john <?xml version="1.0" encoding="UTF-8"?> <ARCXML version="1.1"> <RESPONSE> <FEATURES> <FEATURE> <ENVELOPE minx="-178.216552734375" miny="18.9254779815674" maxx="179.775939941406" maxy="71.3514404296875"/> <FIELDS> <FIELD name="FIPS_CNTRY" value="US" /> <FIELD name="GMI_CNTRY" value="USA" /> <FIELD name="ISO_2DIGIT" value="US" /> <FIELD name="ISO_3DIGIT" value="USA" /> <FIELD name="CNTRY_NAME" value="United States" /> <FIELD name="LONG_NAME" value="United States" /> <FIELD name="SOVEREIGN" value="United States" /> <FIELD name="POP_CNTRY" value="258833000" /> <FIELD name="CURR_TYPE" value="US Dollar" /> <FIELD name="CURR_CODE" value="USD" /> <FIELD name="LANDLOCKED" value="N" /> <FIELD name="SQKM" value="9449365" /> <FIELD name="SQMI" value="3648399.75" /> <FIELD name="COLORMAP" value="5" /> <FIELD name="#SHAPE#" value="[Geometry]" /> <FIELD name="#ID#" value="234" /> </FIELDS> </FEATURE> <FEATURECOUNT count="1" hasmore="false" /> <ENVELOPE minx="-178.216552734375" miny="18.9254779815674" maxx="179.775939941406" maxy="71.3514404296875"/> </FEATURES> </RESPONSE> </ARCXML> {"RESPONSE":[{"ENVELOPE":{"@miny":"18.9254779815674","@minx":"-178.216552734375","@maxy":"71.3514404296875","@maxx":"179.775939941406"},"FEATURECOUNT":{"@hasmore":"false","@count":"1"},"FEATURE":{"ENVELOPE":{"@miny":"18.9254779815674","@minx":"-178.216552734375","@maxy":"71.3514404296875","@maxx":"179.775939941406"},"FIELDS":[{"@name":"FIPS_CNTRY","@value":"US"},{"@name":"GMI_CNTRY","@value":"USA"},{"@name":"ISO_2DIGIT","@value":"US"},{"@name":"ISO_3DIGIT","@value":"USA"},{"@name":"CNTRY_NAME","@value":"United States"},{"@name":"LONG_NAME","@value":"United States"},{"@name":"SOVEREIGN","@value":"United States"},{"@name":"POP_CNTRY","@value":"258833000"},{"@name":"CURR_TYPE","@value":"US Dollar"},{"@name":"CURR_CODE","@value":"USD"},{"@name":"LANDLOCKED","@value":"N"},{"@name":"SQKM","@value":"9449365"},{"@name":"SQMI","@value":"3648399.75"},{"@name":"COLORMAP","@value":"5"},{"@name":"#SHAPE#","@value":"[Geometry]"},{"@name":"#ID#","@value":"234"}]}}],"@version":"1.1"} Andres Almiray wrote: > Hi John, > > Sorry for the late reply. The answer is yes and no, let me explain. > XMLSerializer has an option to expose a value's type when serializing > JSON to XML, that information is written as an attribute named 'type'. > When reading it is assumed you want to recover that information if > 'type' is an attribute of a node, but it seems that in your case type > has a business meaning and should be treated like that instead of a > construct of the library. The same will happen with an attributed > named 'class' by the way. > > Let me look for an alternative that is backward compatible at the same > time. > > Cheers, > Andres > > ------------------------------------------- > http://jroller.com/page/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: John Cartwright <Joh...@no...> > To: jso...@li... > Sent: Monday, October 8, 2007 10:29:37 AM > Subject: [json-lib-user] XML -> JSON, "type" attribute omitted? > > Hello All, > > It seems to me that when converting XML to JSON, elements w/ an > attribute named "type" have that attribute omitted. Is this expected > behavior? > > Thanks! > > -- john > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > json-lib-user mailing list > jso...@li... > https://lists.sourceforge.net/lists/listinfo/json-lib-user > > > ------------------------------------------------------------------------ > Catch up on fall's hot new shows > <http://us.rd.yahoo.com/tv/mail/tagline/falltv/evt=47093/*http://tv.yahoo.com/collections/3658%20> > on Yahoo! TV. Watch previews, get listings, and more! ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs |
From: John C. <Joh...@no...> - 2007-12-05 23:42:55
|
Hi Andres, is it possible that an XML element named features would have the same trouble? I'm finding the XML listed below is serializing to JSON w/o that element. Thanks! -- john <?xml version="1.0" encoding="UTF-8"?> <ARCXML version="1.1"> <RESPONSE> <FEATURES> <FEATURE> <ENVELOPE minx="-178.216552734375" miny="18.9254779815674" maxx="179.775939941406" maxy="71.3514404296875"/> <FIELDS> <FIELD name="FIPS_CNTRY" value="US" /> <FIELD name="GMI_CNTRY" value="USA" /> <FIELD name="ISO_2DIGIT" value="US" /> <FIELD name="ISO_3DIGIT" value="USA" /> <FIELD name="CNTRY_NAME" value="United States" /> <FIELD name="LONG_NAME" value="United States" /> <FIELD name="SOVEREIGN" value="United States" /> <FIELD name="POP_CNTRY" value="258833000" /> <FIELD name="CURR_TYPE" value="US Dollar" /> <FIELD name="CURR_CODE" value="USD" /> <FIELD name="LANDLOCKED" value="N" /> <FIELD name="SQKM" value="9449365" /> <FIELD name="SQMI" value="3648399.75" /> <FIELD name="COLORMAP" value="5" /> <FIELD name="#SHAPE#" value="[Geometry]" /> <FIELD name="#ID#" value="234" /> </FIELDS> </FEATURE> <FEATURECOUNT count="1" hasmore="false" /> <ENVELOPE minx="-178.216552734375" miny="18.9254779815674" maxx="179.775939941406" maxy="71.3514404296875"/> </FEATURES> </RESPONSE> </ARCXML> {"RESPONSE":[{"ENVELOPE":{"@miny":"18.9254779815674","@minx":"-178.216552734375","@maxy":"71.3514404296875","@maxx":"179.775939941406"},"FEATURECOUNT":{"@hasmore":"false","@count":"1"},"FEATURE":{"ENVELOPE":{"@miny":"18.9254779815674","@minx":"-178.216552734375","@maxy":"71.3514404296875","@maxx":"179.775939941406"},"FIELDS":[{"@name":"FIPS_CNTRY","@value":"US"},{"@name":"GMI_CNTRY","@value":"USA"},{"@name":"ISO_2DIGIT","@value":"US"},{"@name":"ISO_3DIGIT","@value":"USA"},{"@name":"CNTRY_NAME","@value":"United States"},{"@name":"LONG_NAME","@value":"United States"},{"@name":"SOVEREIGN","@value":"United States"},{"@name":"POP_CNTRY","@value":"258833000"},{"@name":"CURR_TYPE","@value":"US Dollar"},{"@name":"CURR_CODE","@value":"USD"},{"@name":"LANDLOCKED","@value":"N"},{"@name":"SQKM","@value":"9449365"},{"@name":"SQMI","@value":"3648399.75"},{"@name":"COLORMAP","@value":"5"},{"@name":"#SHAPE#","@value":"[Geometry]"},{"@name":"#ID#","@value":"234"}]}}],"@version":"1.1"} Andres Almiray wrote: > Hi John, > > Sorry for the late reply. The answer is yes and no, let me explain. > XMLSerializer has an option to expose a value's type when serializing > JSON to XML, that information is written as an attribute named 'type'. > When reading it is assumed you want to recover that information if > 'type' is an attribute of a node, but it seems that in your case type > has a business meaning and should be treated like that instead of a > construct of the library. The same will happen with an attributed > named 'class' by the way. > > Let me look for an alternative that is backward compatible at the same > time. > > Cheers, > Andres > > ------------------------------------------- > http://jroller.com/page/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: John Cartwright <Joh...@no...> > To: jso...@li... > Sent: Monday, October 8, 2007 10:29:37 AM > Subject: [json-lib-user] XML -> JSON, "type" attribute omitted? > > Hello All, > > It seems to me that when converting XML to JSON, elements w/ an > attribute named "type" have that attribute omitted. Is this expected > behavior? > > Thanks! > > -- john > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > json-lib-user mailing list > jso...@li... > https://lists.sourceforge.net/lists/listinfo/json-lib-user > > > ------------------------------------------------------------------------ > Catch up on fall's hot new shows > <http://us.rd.yahoo.com/tv/mail/tagline/falltv/evt=47093/*http://tv.yahoo.com/collections/3658%20> > on Yahoo! TV. Watch previews, get listings, and more! |
From: Yuen C. L. <yue...@gm...> - 2007-12-04 03:42:49
|
Hi folks, Just to let you all know that, one of my projects -- Mule JIRA Transport has been released: http://www.mulesource.org/display/JIRA It uses JSON-lib extensively to enable easily definable objects in Mule configuration file. If you haven't had an idea about what Mule is, it is one of the leading open source ESB: http://mule.mulesource.org My project was initially started using SOJO instead of JSON-lib but then switched as I found that it is not being actively maintained. Anyway, thanks for all the promptly responses / fixes whenever I hit into problems. :-) -- Cheers, Yuen-Chi Lian "I do not seek; I find." - Pablo Picasso |
From: Andres A. <aal...@ya...> - 2007-11-08 16:57:17
|
I noticed that too while testing the first issue, I'll look further into it and let you know. ----- Original Message ---- From: Arash Amiri <ara...@re...> To: jso...@li... Sent: Thursday, November 8, 2007 7:58:34 AM Subject: [json-lib-user] quotes in value string when special characters in value Hi Now I have the following problem: Assume my JSON Object looks like this: {'fields':[{"name":"Test1","value":"{Value1}"}, {"name":"Test2","value":"Value2"}, ]} when I convert it to a JSONArray and then try to get the first value by using JSONObject.getString( "value" ) the value is "{{{Value1}}}" (with the quotes sorrounding it!!!) for Value2 it works perfectly (no quotes) the same happens for value such as [Value1] (gets converted to "[Value1]") any ideas how I can change this behaviour? Please help. greetings, arash ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ json-lib-user mailing list jso...@li... https://lists.sourceforge.net/lists/listinfo/json-lib-user __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Arash A. <ara...@re...> - 2007-11-08 13:59:26
|
Hi Now I have the following problem: Assume my JSON Object looks like this: {'fields':[{"name":"Test1","value":"{Value1}"}, {"name":"Test2","value":"Value2"}, ]} when I convert it to a JSONArray and then try to get the first value by using JSONObject.getString( "value" ) the value is "{{{Value1}}}" (with the quotes sorrounding it!!!) for Value2 it works perfectly (no quotes) the same happens for value such as [Value1] (gets converted to "[Value1]") any ideas how I can change this behaviour? Please help. greetings, arash |
From: Arash A. <ara...@re...> - 2007-11-08 12:50:55
|
ok, I guess I was using a very old (0.9) version of the jason-lib. I'll try this new one (2.2-SNAPSHOT) thanks, arash Andres Almiray schrieb: > I tested against the current dev version (2.2-SNAPSHOT) that has > changed little from 2.1 and it runs fine. > May I know which version of the library are you using? > > Here is the testcase I ran (besides the string you provided) > > public void testFromObjectCurliesOnString() { > String json = "{'prop':'{value}'}"; > JSONObject jsonObject = JSONObject.fromObject( json ); > assertNotNull( jsonObject ); > assertEquals( 1, jsonObject.size() ); > assertEquals( "\"{value}\"", jsonObject.get( "prop" ) ); > > json = "{'prop':'{{value}}'}"; > jsonObject = JSONObject.fromObject( json ); > assertNotNull( jsonObject ); > assertEquals( 1, jsonObject.size() ); > assertEquals( "\"{{value}}\"", jsonObject.get( "prop" ) ); > > json = "{'prop':'{{{value}}}'}"; > jsonObject = JSONObject.fromObject( json ); > assertNotNull( jsonObject ); > assertEquals( 1, jsonObject.size() ); > assertEquals( "\"{{{value}}}\"", jsonObject.get( "prop" ) ); > } > > > Regards, > Andres > > ----- Original Message ---- > From: Arash Amiri <ara...@re...> > To: jso...@li... > Sent: Wednesday, November 7, 2007 9:32:01 AM > Subject: [json-lib-user] How to escape curly braces in JSON > > Hi > I have a (I guess simple) question: > > I have a JSONString in Java such as > > String jsonString = "{ 'fields': [ > {name: 'Firstname{{}}',value: '{{{Tom}}}',attributes: [],}, > {name: 'Lastname',value: 'Meier',attributes: [],}, > {name: 'Knows',value: 'Frec',attributes: [{ name: 'Since', value: > '2000' }],}, > {name: 'Knows',value: 'Kim',attributes: [{ name: 'Since', value: > '2003' }],}, > {name: 'Knows',value: 'Mark',attributes: [{ name: 'Since', value: > '2002' }, > { name: 'From', value: 'Reports' }]} > ]}" > > When I use JSONObject jsonForm = new JSONObject(jsonString); > > I get an Exception: > > net.sf.json.JSONException: Expected a ':' after a key at character 7 > of {{{Tom}}} > > I dont get this. The braces are inside quotes, there should not be a > problem, or??? > > please help > greetings, arash > > > ------------------------------------------------------------------------- > This SF.net <http://SF.net> email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > json-lib-user mailing list > jso...@li... > <mailto:jso...@li...> > https://lists.sourceforge.net/lists/listinfo/json-lib-user > > > __________________________________________________ > Do You Yahoo!? > Tired of spam? Yahoo! Mail has the best spam protection around > http://mail.yahoo.com |
From: Andres A. <aal...@ya...> - 2007-11-08 05:29:20
|
I tested against the current dev version (2.2-SNAPSHOT) that has changed little from 2.1 and it runs fine. May I know which version of the library are you using? Here is the testcase I ran (besides the string you provided) public void testFromObjectCurliesOnString() { String json = "{'prop':'{value}'}"; JSONObject jsonObject = JSONObject.fromObject( json ); assertNotNull( jsonObject ); assertEquals( 1, jsonObject.size() ); assertEquals( "\"{value}\"", jsonObject.get( "prop" ) ); json = "{'prop':'{{value}}'}"; jsonObject = JSONObject.fromObject( json ); assertNotNull( jsonObject ); assertEquals( 1, jsonObject.size() ); assertEquals( "\"{{value}}\"", jsonObject.get( "prop" ) ); json = "{'prop':'{{{value}}}'}"; jsonObject = JSONObject.fromObject( json ); assertNotNull( jsonObject ); assertEquals( 1, jsonObject.size() ); assertEquals( "\"{{{value}}}\"", jsonObject.get( "prop" ) ); } Regards, Andres ----- Original Message ---- From: Arash Amiri <ara...@re...> To: jso...@li... Sent: Wednesday, November 7, 2007 9:32:01 AM Subject: [json-lib-user] How to escape curly braces in JSON Hi I have a (I guess simple) question: I have a JSONString in Java such as String jsonString = "{ 'fields': [ {name: 'Firstname{{}}',value: '{{{Tom}}}',attributes: [],}, {name: 'Lastname',value: 'Meier',attributes: [],}, {name: 'Knows',value: 'Frec',attributes: [{ name: 'Since', value: '2000' }],}, {name: 'Knows',value: 'Kim',attributes: [{ name: 'Since', value: '2003' }],}, {name: 'Knows',value: 'Mark',attributes: [{ name: 'Since', value: '2002' }, { name: 'From', value: 'Reports' }]} ]}" When I use JSONObject jsonForm = new JSONObject(jsonString); I get an Exception: net.sf.json.JSONException: Expected a ':' after a key at character 7 of {{{Tom}}} I dont get this. The braces are inside quotes, there should not be a problem, or??? please help greetings, arash ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ json-lib-user mailing list jso...@li... https://lists.sourceforge.net/lists/listinfo/json-lib-user __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Andres A. <aal...@ya...> - 2007-11-07 20:46:41
|
Hmm it should work the same way as having "{'prop':'[something]'}" If it doesn't then it is a bug, I'll review it tonight and let you know my findings. Cheers, Andres ----- Original Message ---- From: Yuen Chi Lian <yue...@gm...> To: Arash Amiri <ara...@re...> Cc: jso...@li... Sent: Wednesday, November 7, 2007 12:11:35 PM Subject: Re: [json-lib-user] How to escape curly braces in JSON Hi Arashi, Have you tried using backslash, e.g. '\{'? That should work. On Nov 7, 2007 11:32 PM, Arash Amiri <ara...@re...> wrote: > Hi > I have a (I guess simple) question: > > I have a JSONString in Java such as > > String jsonString = "{ 'fields': [ > {name: 'Firstname{{}}',value: '{{{Tom}}}',attributes: [],}, > {name: 'Lastname',value: 'Meier',attributes: [],}, > {name: 'Knows',value: 'Frec',attributes: [{ name: 'Since', value: > '2000' }],}, > {name: 'Knows',value: 'Kim',attributes: [{ name: 'Since', value: > '2003' }],}, > {name: 'Knows',value: 'Mark',attributes: [{ name: 'Since', value: > '2002' }, > { name: 'From', value: 'Reports' }]} > ]}" > > When I use JSONObject jsonForm = new JSONObject(jsonString); > > I get an Exception: > > net.sf.json.JSONException: Expected a ':' after a key at character 7 > of {{{Tom}}} > > I dont get this. The braces are inside quotes, there should not be a > problem, or??? > > please help > greetings, arash > > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Splunk Inc. > Still grepping through log files to find problems? Stop. > Now Search log events and configuration files using AJAX and a browser. > Download your FREE copy of Splunk now >> http://get.splunk.com/ > _______________________________________________ > json-lib-user mailing list > jso...@li... > https://lists.sourceforge.net/lists/listinfo/json-lib-user > -- Cheers, Yuen-Chi Lian "I do not seek; I find." - Pablo Picasso ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ json-lib-user mailing list jso...@li... https://lists.sourceforge.net/lists/listinfo/json-lib-user __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |