json-lib-user Mailing List for Json-lib (Page 7)
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...> - 2008-02-12 17:45:34
|
Hi Manos, Json-lb is capable of serializing Hibernate/JPA beans, other users have requested some features that may help you in your tests, for example skipping transient fields, @Transient annotated fields, JsonBeanProcessorMatcher and JsonValueProcessorMatcher capable of matching subclasses (like CGLIB proxies). 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: Manos Batsis <man...@ge...> To: jso...@li... Sent: Tuesday, February 12, 2008 5:16:38 AM Subject: [json-lib-user] Hibernate Beans Hello, Just wanted to see whether serializing Hibernate javabeans (or EJB3 Entity beans) to JSON works. Hibernate beans have CGLIB generated proxies for their properties and that sometimes causes problems with serializers in general. Many thanks, Manos ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ 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: Manos B. <man...@ge...> - 2008-02-12 13:26:19
|
Hello, Just wanted to see whether serializing Hibernate javabeans (or EJB3 Entity beans) to JSON works. Hibernate beans have CGLIB generated proxies for their properties and that sometimes causes problems with serializers in general. Many thanks, Manos |
From: Andres A. <aal...@ya...> - 2008-02-05 01:07:33
|
Anil, That is the expected behavior because numbers in JSON can never by null, only objects. It may be a bit confusing at first because numbers in java come in two flavors: primitive and wrappers, wrappers being objects after all. But there is a way to override this behavior, you may register a DefaultValueProcessor to return whatever value (any valid json value that is) that your app requires. 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: Anil Gangolli <an...@bu...> To: jso...@li... Sent: Monday, February 4, 2008 5:04:11 PM Subject: [json-lib-user] Question about null Number serialization Apologies if this is a FAQ, but I tried for some time to find it and couldn't. If I have a bean with a Long or Number property, e.g. class TestBean { private Long number = null; public Long getNumber() { return number; } public void setNumber(Long number) { this.number = number; } } and serialize an instance where the "number" property is null, for example using JSONSerializer.toJSON(new TestBean()).toString() it gives the result {"number":0} and deserializing this gives an instance that is not equal to the original. Is this expected or a bug? I was expecting a serialized form of {"number":null} which, when deserialized does give me an instance equal to the original. --a. -----Inline Attachment Follows----- ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ -----Inline Attachment Follows----- _______________________________________________ json-lib-user mailing list jso...@li... https://lists.sourceforge.net/lists/listinfo/json-lib-user ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |
From: Anil G. <an...@bu...> - 2008-02-05 01:04:14
|
Apologies if this is a FAQ, but I tried for some time to find it and couldn't. If I have a bean with a Long or Number property, e.g. class TestBean { private Long number = null; public Long getNumber() { return number; } public void setNumber(Long number) { this.number = number; } } and serialize an instance where the "number" property is null, for example using JSONSerializer.toJSON(new TestBean()).toString() it gives the result {"number":0} and deserializing this gives an instance that is not equal to the original. Is this expected or a bug? I was expecting a serialized form of {"number":null} which, when deserialized does give me an instance equal to the original. --a. |
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 |
From: Haritha J. <har...@ya...> - 2008-01-21 19:34:17
|
------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ |
From: Haritha J. <har...@ya...> - 2008-01-21 18:36:05
|
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=columns 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 home page. http://www.yahoo.com/r/hs |
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 |
From: Haritha J. <har...@ya...> - 2008-01-17 21:18:37
|
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 ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping |
From: David R. <dwr...@lb...> - 2008-01-13 01:17:23
|
Unfortunately I just get a 500 error from the server, with no stack trace logged in the Tomcat log, even though I surround the call with a try and catch both JSONException and Exception. The complete code for the servlet is attached. I am including all the Axis2 1.3 jar's in the CLASSPATH as part of this application, and I noticed there are some JSON-related jar's in them. I tried not including them, with the same result. -David Andres Almiray wrote: > Hi David, > > Do you have a full stack trace of the error? it might help to shed > some light into your problem. > > 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: David Robertson <dwr...@lb...> > To: jso...@li... > Sent: Friday, January 11, 2008 4:40:36 PM > Subject: [json-lib-user] hopefully simple question about JSONObject > > I am a newbie to Json-lib and am trying to create a JSONObject within a > Java 1.5 servlet. I am using json-lib-2.2-jdk15.jar > > I have the following code: > > Map outputMap = new HashMap(); > outputMap.put("var1", "value1"); > JSONObject jsonObject = JSONObject.fromObject(outputMap) > > The servlet dies on the last line of code. I have tried the > JSONSerializer version from the snippets as well with the same result. > The answer is probably staring me in the face, but I don't see it. > > > > ------------------------------------------------------------------------- > Check out the new SourceForge.net <http://SourceForge.net> Marketplace. > It's the best place to buy or sell services for > just about anything Open Source. > http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace > _______________________________________________ > json-lib-user mailing list > jso...@li... > <mailto:jso...@li...> > https://lists.sourceforge.net/lists/listinfo/json-lib-user > > > ------------------------------------------------------------------------ > 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...> - 2008-01-12 00:43:01
|
Hi David, Do you have a full stack trace of the error? it might help to shed some light into your problem. 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: David Robertson <dwr...@lb...> To: jso...@li... Sent: Friday, January 11, 2008 4:40:36 PM Subject: [json-lib-user] hopefully simple question about JSONObject I am a newbie to Json-lib and am trying to create a JSONObject within a Java 1.5 servlet. I am using json-lib-2.2-jdk15.jar I have the following code: Map outputMap = new HashMap(); outputMap.put("var1", "value1"); JSONObject jsonObject = JSONObject.fromObject(outputMap) The servlet dies on the last line of code. I have tried the JSONSerializer version from the snippets as well with the same result. The answer is probably staring me in the face, but I don't see it. ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace _______________________________________________ json-lib-user mailing list jso...@li... https://lists.sourceforge.net/lists/listinfo/json-lib-user ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |
From: David R. <dwr...@lb...> - 2008-01-12 00:40:49
|
I am a newbie to Json-lib and am trying to create a JSONObject within a Java 1.5 servlet. I am using json-lib-2.2-jdk15.jar I have the following code: Map outputMap = new HashMap(); outputMap.put("var1", "value1"); JSONObject jsonObject = JSONObject.fromObject(outputMap) The servlet dies on the last line of code. I have tried the JSONSerializer version from the snippets as well with the same result. The answer is probably staring me in the face, but I don't see it. |
From: Andrew S. <str...@gm...> - 2008-01-07 21:49:43
|
I figured out what was causing this... My project is also using the apache portals bridges groovy bridge and it has a dependency on Groovy 1.0. Clearly it was using Groovy 1.0 classes instead of the 1.5.1 classes I was expecting which was probably causing Groovy to use the wrong methods of invoking constructors. I marked the Groovy 1.0dependency as provided in my POM and cleared up this issue. On Jan 7, 2008 1:21 PM, Andres Almiray <aal...@ya...> wrote: > Hi Andrew, > > The code should work with 1.5.0, as a matter of fact a bug in > DelegatingMetaClass was fixed to get it working. > Perhaps something was changed again in 1.5.1, I'll give it a look and let > you know. > > 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: Andrew Strickland <str...@gm...> > To: jso...@li... > Sent: Monday, January 7, 2008 9:09:38 AM > Subject: [json-lib-user] StringMetaClass Problem > > Hello, > > I'm having a problem using the JsonGroovyBuilder. I'm using Json-lib 2.2and Groovy > 1.5.1, they are declared in my POM like so: > > <dependency> > <groupId>net.sf.json-lib</groupId> > <artifactId>json-lib</artifactId> > <version>2.2</version> > <classifier>jdk15</classifier> > </dependency> > > <dependency> > <groupId> org.codehaus.groovy</groupId> > <artifactId>groovy-all</artifactId> > <version>1.5.1</version> > </dependency> > > Here's the snippet from my groovy script where I try to do the json > creation: > > def builder = new JsonGroovyBuilder(); > > if (searchResponse != null) { > def orders = builder.orders{ > for(ord in ords){ > order{ > tsrNumber = ord.getTsrNumber() > tsoNumber = ord.getTsrNumber() > ccsd = ord.getCcsdNumber() > status = ord.getStatus() > } > } > } > } > > I get the following exception: > > ERROR [Groovy] - Servlet.service() for servlet Groovy threw exception > java.lang.NoSuchMethodException: > groovy.runtime.metaclass.java.lang.StringMetaCl > ass.<init>( groovy.lang.MetaClassRegistry, java.lang.Class) > at java.lang.Class.getConstructor0(Unknown Source) > at java.lang.Class.getConstructor(Unknown Source) > at groovy.lang.MetaClassRegistry.getMetaClassFor ( > MetaClassRegistry.java: > 205) > at groovy.lang.MetaClassRegistry.getMetaClass( > MetaClassRegistry.java:135 > ) > at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java > :118) > at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod(InvokerHelper. > java:111) > at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN > (Scrip > tBytecodeAdapter.java:187) > at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.isCase(ScriptByteco > > deAdapter.java:715) > at proxy.proxy(proxy.groovy:27) > at gjdk.proxy_GroovyReflector.invoke(Unknown Source) > at groovy.lang.MetaMethod.invoke(MetaMethod.java:115) > at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke(MetaClassH > elper.java:713) > at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560) > at > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurre > ntN(ScriptBytecodeAdapter.java :97) > at > org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurre > nt0(ScriptBytecodeAdapter.java:129) > at proxy.run(proxy.groovy:15) > at groovy.util.GroovyScriptEngine.run(GroovyScriptEngine.java:378) > at groovy.servlet.GroovyServlet$1.call(GroovyServlet.java:135) > at org.codehaus.groovy.runtime.GroovyCategorySupport.use > (GroovyCategoryS > upport.java:149) > at groovy.servlet.GroovyServlet.service (GroovyServlet.java:144) > at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) > at > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl > icationFilterChain.java:269) > at org.apache.catalina.core.ApplicationFilterChain.doFilter > (ApplicationF > ilterChain.java:188) > at org.apache.catalina.core.StandardWrapperValve.invoke > (StandardWrapperV > alve.java:213) > at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV > alve.java:174) > at org.apache.catalina.core.StandardHostValve.invoke( > StandardHostValve.j > ava:127) > at org.apache.catalina.valves.ErrorReportValve.invoke( > ErrorReportValve.j > ava:117) > at org.apache.catalina.core.StandardEngineValve.invoke > (StandardEngineVal > ve.java:108) > at org.apache.catalina.connector.CoyoteAdapter.service( > CoyoteAdapter.jav > a:151) > at org.apache.coyote.http11.Http11Processor.process ( > Http11Processor.java > :874) > at > org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p > rocessConnection(Http11BaseProtocol.java:665) > at org.apache.tomcat.util.net<http://org.apache.tomcat.util.net.PoolTcpEndpoint.pro>.PoolTcpEndpoint.processSocket > (PoolTcpEndpo > int.java:528) > at org.apache.tomcat.util.net<http://org.apache.tomcat.util.net.LeaderFollowerWorkerThread.ru> > .LeaderFollowerWorkerThread.runIt(LeaderFol > lowerWorkerThread.java:81) > at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP > > ool.java:689) > at java.lang.Thread.run(Unknown Source) > > I checked the json-lib source browser for StringMetaClass and noticed a > difference between revision 1.1 and 1.2, you can see it here: > http://json-lib.cvs.sourceforge.net/json-lib/json-lib/src/main/groovy/groovy/runtime/metaclass/java/lang/StringMetaClass.groovy?r1=1.1&r2=1.2. > > Notice that the constructor that took a MetaClassRegistry and Class is now > gone...and that appears to be the constructor that Groovy is trying to > instantiate. Anyone have any idea why this is happening, if there is a fix > for it, or how I can get around it? > > > ------------------------------ > 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+> > |
From: Andres A. <aal...@ya...> - 2008-01-07 18:21:40
|
Hi Andrew, The code should work with 1.5.0, as a matter of fact a bug in DelegatingMetaClass was fixed to get it working. Perhaps something was changed again in 1.5.1, I'll give it a look and let you know. 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: Andrew Strickland <str...@gm...> To: jso...@li... Sent: Monday, January 7, 2008 9:09:38 AM Subject: [json-lib-user] StringMetaClass Problem Hello, I'm having a problem using the JsonGroovyBuilder. I'm using Json-lib 2.2 and Groovy 1.5.1, they are declared in my POM like so: <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.2</version> <classifier>jdk15</classifier> </dependency> <dependency> <groupId> org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>1.5.1</version> </dependency> Here's the snippet from my groovy script where I try to do the json creation: def builder = new JsonGroovyBuilder(); if (searchResponse != null) { def orders = builder.orders{ for(ord in ords){ order{ tsrNumber = ord.getTsrNumber() tsoNumber = ord.getTsrNumber() ccsd = ord.getCcsdNumber() status = ord.getStatus() } } } } I get the following exception: ERROR [Groovy] - Servlet.service() for servlet Groovy threw exception java.lang.NoSuchMethodException: groovy.runtime.metaclass.java.lang.StringMetaCl ass.<init>( groovy.lang.MetaClassRegistry, java.lang.Class) at java.lang.Class.getConstructor0(Unknown Source) at java.lang.Class.getConstructor(Unknown Source) at groovy.lang.MetaClassRegistry.getMetaClassFor (MetaClassRegistry.java: 205) at groovy.lang.MetaClassRegistry.getMetaClass(MetaClassRegistry.java:135 ) at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java:118) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod (InvokerHelper. java:111) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN(Scrip tBytecodeAdapter.java:187) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.isCase(ScriptByteco deAdapter.java:715) at proxy.proxy(proxy.groovy:27) at gjdk.proxy_GroovyReflector.invoke(Unknown Source) at groovy.lang.MetaMethod.invoke(MetaMethod.java:115) at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke (MetaClassH elper.java:713) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurre ntN(ScriptBytecodeAdapter.java :97) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurre nt0(ScriptBytecodeAdapter.java:129) at proxy.run(proxy.groovy:15) at groovy.util.GroovyScriptEngine.run(GroovyScriptEngine.java :378) at groovy.servlet.GroovyServlet$1.call(GroovyServlet.java:135) at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategoryS upport.java:149) at groovy.servlet.GroovyServlet.service (GroovyServlet.java:144) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl icationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF ilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV alve.java:213) at org.apache.catalina.core.StandardContextValve.invoke (StandardContextV alve.java:174) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j ava:127) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j ava:117) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal ve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.jav a:151) at org.apache.coyote.http11.Http11Processor.process (Http11Processor.java :874) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p rocessConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket (PoolTcpEndpo int.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFol lowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP ool.java:689) at java.lang.Thread.run(Unknown Source) I checked the json-lib source browser for StringMetaClass and noticed a difference between revision 1.1 and 1.2, you can see it here: http://json-lib.cvs.sourceforge.net/json-lib/json-lib/src/main/groovy/groovy/runtime/metaclass/java/lang/StringMetaClass.groovy?r1=1.1&r2=1.2. Notice that the constructor that took a MetaClassRegistry and Class is now gone...and that appears to be the constructor that Groovy is trying to instantiate. Anyone have any idea why this is happening, if there is a fix for it, or how I can get around it? ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |
From: Andrew S. <str...@gm...> - 2008-01-07 17:09:43
|
Hello, I'm having a problem using the JsonGroovyBuilder. I'm using Json-lib 2.2and Groovy 1.5.1, they are declared in my POM like so: <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.2</version> <classifier>jdk15</classifier> </dependency> <dependency> <groupId>org.codehaus.groovy</groupId> <artifactId>groovy-all</artifactId> <version>1.5.1</version> </dependency> Here's the snippet from my groovy script where I try to do the json creation: def builder = new JsonGroovyBuilder(); if (searchResponse != null) { def orders = builder.orders{ for(ord in ords){ order{ tsrNumber = ord.getTsrNumber() tsoNumber = ord.getTsrNumber() ccsd = ord.getCcsdNumber() status = ord.getStatus() } } } } I get the following exception: ERROR [Groovy] - Servlet.service() for servlet Groovy threw exception java.lang.NoSuchMethodException: groovy.runtime.metaclass.java.lang.StringMetaCl ass.<init>(groovy.lang.MetaClassRegistry, java.lang.Class) at java.lang.Class.getConstructor0(Unknown Source) at java.lang.Class.getConstructor(Unknown Source) at groovy.lang.MetaClassRegistry.getMetaClassFor( MetaClassRegistry.java: 205) at groovy.lang.MetaClassRegistry.getMetaClass(MetaClassRegistry.java :135 ) at org.codehaus.groovy.runtime.Invoker.invokeMethod(Invoker.java :118) at org.codehaus.groovy.runtime.InvokerHelper.invokeMethod (InvokerHelper. java:111) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodN (Scrip tBytecodeAdapter.java:187) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.isCase (ScriptByteco deAdapter.java:715) at proxy.proxy(proxy.groovy:27) at gjdk.proxy_GroovyReflector.invoke(Unknown Source) at groovy.lang.MetaMethod.invoke(MetaMethod.java:115) at org.codehaus.groovy.runtime.MetaClassHelper.doMethodInvoke (MetaClassH elper.java:713) at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:560) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurre ntN(ScriptBytecodeAdapter.java:97) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.invokeMethodOnCurre nt0(ScriptBytecodeAdapter.java:129) at proxy.run(proxy.groovy:15) at groovy.util.GroovyScriptEngine.run(GroovyScriptEngine.java:378) at groovy.servlet.GroovyServlet$1.call(GroovyServlet.java:135) at org.codehaus.groovy.runtime.GroovyCategorySupport.use (GroovyCategoryS upport.java:149) at groovy.servlet.GroovyServlet.service(GroovyServlet.java:144) at javax.servlet.http.HttpServlet.service(HttpServlet.java:803) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter (Appl icationFilterChain.java:269) at org.apache.catalina.core.ApplicationFilterChain.doFilter (ApplicationF ilterChain.java:188) at org.apache.catalina.core.StandardWrapperValve.invoke (StandardWrapperV alve.java:213) at org.apache.catalina.core.StandardContextValve.invoke (StandardContextV alve.java:174) at org.apache.catalina.core.StandardHostValve.invoke( StandardHostValve.j ava:127) at org.apache.catalina.valves.ErrorReportValve.invoke( ErrorReportValve.j ava:117) at org.apache.catalina.core.StandardEngineValve.invoke (StandardEngineVal ve.java:108) at org.apache.catalina.connector.CoyoteAdapter.service( CoyoteAdapter.jav a:151) at org.apache.coyote.http11.Http11Processor.process( Http11Processor.java :874) at org.apache.coyote.http11.Http11BaseProtocol$Http11ConnectionHandler.p rocessConnection(Http11BaseProtocol.java:665) at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket (PoolTcpEndpo int.java:528) at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt (LeaderFol lowerWorkerThread.java:81) at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run (ThreadP ool.java:689) at java.lang.Thread.run(Unknown Source) I checked the json-lib source browser for StringMetaClass and noticed a difference between revision 1.1 and 1.2, you can see it here: http://json-lib.cvs.sourceforge.net/json-lib/json-lib/src/main/groovy/groovy/runtime/metaclass/java/lang/StringMetaClass.groovy?r1=1.1&r2=1.2. Notice that the constructor that took a MetaClassRegistry and Class is now gone...and that appears to be the constructor that Groovy is trying to instantiate. Anyone have any idea why this is happening, if there is a fix for it, or how I can get around it? |
From: Andres A. <aal...@ya...> - 2007-12-22 00:55:50
|
Hi All, In order to dispel confusion on how to use Json-lib and some of its features I have created a page on the project site outlining basic usages. The idea is to enrich that page with further examples as features come by. The page is located at http://json-lib.sourceforge.net/snippets.html 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. ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |
From: Andres A. <aal...@ya...> - 2007-12-22 00:53:15
|
Dear Users, I'm pleased to announce that Json-lib version 2.2 has been released. Changelog:Add a chained version of remove to JSONObject.Initial generics support. Many thanks to Matt Small (and WaveMaker) (provided patch and tests). (rolled-back)Extra quotes on string values with {} and [] Fixes1855019 JSONUtils.mayBeJSON is broken.1847116 Add support of Sets in JSONObject.toBean1832146 Don't require the user to register Enum morphs by hand1832041 Ignore getters annotated with @Transient. Thanks to Dan Fabulich (provided workaround)1832047 Use private no-arg constructors when available. Thanks to Dan Fabulich (provided workaround)1832139 Enums should be serialized by name(), not by String.valueOf. Thanks to Dan Fabulich (provided workaround)1832055 NewBeanInstanceStrategy ignored when you pass a root obj1828093 JSONArray.toArray can't transform from String[] to int[]1819159 Encoding problem of XMLSerializer#writeDocument. Thanks to Masato Nagai (provided a patch)1815457 Allow direct property acces when transforming JSON to Java. Thanks to Gino Miceli (provided a patch)1815456 Allow default value to be changed when a reference is null1813520 Allow 'type' to be parsed from XML to JSON1813301 JSONObject.toBean throws NPE with JSONArray values. Thanks to Mino Togna (provided a testcase)1812682 Byte and Short arrays throw an IllegalArgumentException ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |
From: Andres A. <aal...@ya...> - 2007-12-20 05:42:38
|
Hi John, It should be in the same timezone where it was created, if you have an app that requires specific timezones then changes must be made as the default serialization for java.util.Date doesn't take timezone into account, as well as DateMorpher and MapToDateMorpher from EZMorph. Please raise a FR on the issue tracker, thanks. Cheers, Andres ----- Original Message ---- From: John Xiao <cod...@gm...> To: jso...@li... Sent: Wednesday, December 19, 2007 9:09:46 PM Subject: [json-lib-user] java.util.Date Default json format for java.util.Date is { "minutes": 13, "seconds": 14, "hours": 12, "month": 5, "year": 2007, "day": 17, "milliseconds": 150 } I don't see timezone information anywhere. Is it in UTC? thanks, John X. -- Don't underestimate the Force! ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |
From: John X. <cod...@gm...> - 2007-12-20 05:09:48
|
Default json format for java.util.Date is { "minutes": 13, "seconds": 14, "hours": 12, "month": 5, "year": 2007, "day": 17, "milliseconds": 150 } I don't see timezone information anywhere. Is it in UTC? thanks, John X. -- Don't underestimate the Force! |
From: Andres A. <aal...@ya...> - 2007-12-13 05:19:00
|
Hi HAritha,=0A=0AOn closer inspection Json-lib is doing the correct thing b= y not converting the value of your property 'JSON' into a JSONObject, even = if it is a well-formed json string. In a previous version it did so, but th= at caused another bug with simpler json strings. So if you want to transfor= m that json string into a JSONObject you'll have to do it yourself. There a= re several options=0A=0A-- Option A=0AJSONObject jsonObj =3D JSONObject.fro= mObject( textField, jsonConfig );=0AjsonObj.set( "JSON", JSONObject.fromObj= ect( jsonObj.getJSONObject( "JSON" ), jsonConfig );=0A=0A-- Option B=0A=0A = JsonConfig jsonConfig =3D new JsonConfig();=0A jsonConfig.registe= rJsonValueProcessor( "JSON", new JsonValueProcessor(){=0A public Ob= ject processArrayValue( Object value, JsonConfig jsonConfig ) {=0A = // not interested in processing the value inside an array=0A = return value;=0A }=0A=0A public Object processObjectValue( = String key, Object value, JsonConfig jsonConfig ) {=0A return JS= ONObject.fromObject(value);=0A }=0A } );=0A JSONObject js= onObject =3D JSONObject.fromObject( textField, jsonConfig );=0A=0ACheers,= =0AAndres=0A=0A----- Original Message ----=0AFrom: Haritha Juturu <haritha.= ju...@ya...>=0ATo: Andres Almiray <aal...@ya...>; json-lib-user@= lists.sourceforge.net=0ASent: Tuesday, December 11, 2007 1:57:52 PM=0ASubje= ct: Re: [json-lib-user] Quick Question on JSON=0A=0A=0AYes i get this excep= tion on calling JSONObject json =3D json.getJSONObject( "JSON" );=0A=0AExce= ption in thread "main" net.sf.json.JSONException: JSONObject["JSON"] is not= a JSONObject.=0A at net.sf.json.JSONObject.getJSONObject(JSONObject.jav= a:1813)=0A at com.splashnote.web.pages.JavaToJson.getJSON(JavaToJson.jav= a:132)=0AHaritha=0A=0A----- Original Message ----=0AFrom: Andres Almiray <a= al...@ya...>=0ATo: Haritha Juturu <har...@ya...>; json-li= b-...@li...=0ASent: Tuesday, December 11, 2007 1:04:11 PM= =0ASubject: Re: [json-lib-user] Quick Question on=0A JSON=0A=0A=0AHi Harith= a,=0A=0AYou are right, if it is a nested JSONObject it should print it with= out the surrounding double quotes. As a last resort, can you call=0A=0AJSON= Object jsonObj =3D JSONObject.fromObject( textField, jsonConfig );=0AJSONOb= ject json =3D json.getJSONObject( "JSON" );=0A=0AIf it really is a JSONObje= ct then no exception should arise. If no exception is thrown then there may= be something going on with the string representation of a JSONObject when = printed.=0A=0AThanks,=0AAndres=0A=0A=0A----- Original Message ----=0AFrom: = Haritha Juturu <har...@ya...>=0ATo:=0A Andres Almiray <aalmiray= @yahoo.com>; jso...@li...=0ASent: Tuesday, December = 11, 2007 12:59:32 PM=0ASubject: Re: [json-lib-user] Quick Question on JSON= =0A=0A=0AHi Andres=0A=0AThe TextField bean looks like this=0Apublic class T= extField(){ =0A private Long parentId;=0A private Long textFieldId;=0A= private String JSON;=0A}=0A=0AAfter executing the code JSONObject jsonO= bj =3D JSONObject.fromObject( textField, jsonConfig ); , i try to print th= is object 'jsonObj" and it prints the name value pair( of JSON Property) wi= th quotes=0A=0A{"parentId":678,"textFieldId":111,"JSON":"{'sizeWidth':620,'= text':'=93[Winning the Nobel Peace Prize]=0A ','positionLeft':20,'style':'l= eft:20px;top:100px;width:620px;height:100px;','positionTop':100,'name':'','= cssClass':'','objectType':'TextObject','sizeHeight':100}"}=0A=0AIf it was c= onverting this 'JSON' property to JSONObject internally, wont it print as= =0A=0A"JSON":=0A{"parentId":678,"textFieldId":111,"JSON":{'sizeWidth':620,'= text':'=93[Winning=0Athe Nobel Peace Prize]=0A','positionLeft':20,'style':'= left:20px;top:100px;width:620px;height:100px;','positionTop':100,'name':'',= 'cssClass':'','objectType':'TextObject','sizeHeight':100}}=0Awithout the qu= otes on the value.=0A=0APlease correct me if i got it wrong=0A=0AI am using= the json-lib-2.1 for jsd 1.5 version.=0AHaritha=0A=0A=0A=0A----- Original = Message ----=0AFrom: Andres Almiray <aal...@ya...>=0ATo: Haritha Jutu= ru <har...@ya...>; jso...@li...=0ASent: = Tuesday, December 11, 2007 12:27:12 PM=0ASubject: Re: [json-lib-user] Quick= Question on JSON=0A=0A=0AHi Haritha,=0A=0AAre you sure the contents of the= named property ('JSON') are not automatically converted into a JSONObject = ? it looks to me like it is a well formed json string, if so it should be c= onverted automatically when you call fromObject() at top level.=0A=0ACan yo= u please tell us which version of Json-lib are you testing with?=0A=0ARegar= ds,=0AAndres=0A=0A----- Original Message ----=0AFrom: Haritha Juturu <harit= ha....@ya...>=0ATo: jso...@li...=0ASent: Tues= day, December 11, 2007 12:16:36 PM=0ASubject: [json-lib-user] Quick Questio= n on JSON=0A=0A=0AHi Everyone=0AI have a line of code=0AJSONObject jsonObj = =3D JSONObject.fromObject( textField, jsonConfig ); =0Awhich produces this= JSON string=0A=0A{"parentId":678,"textFieldId":111,=0A"JSON":=0A"{'sizeWid= th':620,'text':'=93[Winning the Nobel Peace Prize]','positionLeft':20,'styl= e':'left:20px;top:100px;width:620px;height:100px;','positionTop':100,'name'= :'','cssClass':'','objectType':'TextObject','sizeHeight':100}"=0A}=0A=0Anow= if i want the property "json" whose value is a string=0A =93[Winning the N= obel Peace=0APrize]','positionLeft':20,'style':'left:20px;top:100px;width:6= 20px;height:100px;','positionTop':100,'name':'','cssClass':'','objectType':= '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 o= utput should look like =0A{"parentId":678,"textFieldId":111,=0A"JSON": thi= s value is not a string anymore=0A{'sizeWidth':620,'text':'=93[Winning=0Ath= e Nobel Peace=0APrize]','positionLeft':20,'style':'left:20px;top:100px;widt= h:620px;height:100px;','positionTop':100,'name':'','cssClass':'','objectTyp= e':'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, newshound= , 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 Yahoo! Se= arch.=0A=0A=0A=0A=0A=0A=0A=0A=0A Never miss a thing. Make Yahoo your= homepage.=0A=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 ____= ___________________________________________________________________________= _____=0ANever miss a thing. Make Yahoo your home page. =0Ahttp://www.yahoo= .com/r/hs |
From: Haritha J. <har...@ya...> - 2007-12-11 21:58:08
|
Yes i get this exception on calling JSONObject json =3D json.getJSONObject(= "JSON" );=0A=0AException in thread "main" net.sf.json.JSONException: JSONO= bject["JSON"] is not a JSONObject.=0A at net.sf.json.JSONObject.getJSONO= bject(JSONObject.java:1813)=0A at com.splashnote.web.pages.JavaToJson.ge= tJSON(JavaToJson.java:132)=0AHaritha=0A=0A----- Original Message ----=0AFro= m: Andres Almiray <aal...@ya...>=0ATo: Haritha Juturu <haritha.juturu= @yahoo.com>; jso...@li...=0ASent: Tuesday, December = 11, 2007 1:04:11 PM=0ASubject: Re: [json-lib-user] Quick Question on JSON= =0A=0A=0AHi Haritha,=0A=0AYou are right, if it is a nested JSONObject it sh= ould print it without the surrounding double quotes. As a last resort, can = you call=0A=0AJSONObject jsonObj =3D JSONObject.fromObject( textField, json= Config );=0AJSONObject json =3D json.getJSONObject( "JSON" );=0A=0AIf it re= ally is a JSONObject then no exception should arise. If no exception is thr= own then there may be something going on with the string representation of = a JSONObject when printed.=0A=0AThanks,=0AAndres=0A=0A=0A----- Original Mes= sage ----=0AFrom: Haritha Juturu <har...@ya...>=0ATo:=0A Andres= Almiray <aal...@ya...>; jso...@li...=0ASent: = Tuesday, December 11, 2007 12:59:32 PM=0ASubject: Re: [json-lib-user] Quick= Question on JSON=0A=0A=0AHi Andres=0A=0AThe TextField bean looks like this= =0Apublic class TextField(){ =0A private Long parentId;=0A private Lon= g textFieldId;=0A private String JSON;=0A}=0A=0AAfter executing the code= JSONObject jsonObj =3D JSONObject.fromObject( textField, jsonConfig ); , = i try to print this object 'jsonObj" and it prints the name value pair( of = JSON Property) with quotes=0A=0A{"parentId":678,"textFieldId":111,"JSON":"{= 'sizeWidth':620,'text':'=93[Winning the Nobel Peace Prize]=0A ','positionLe= ft':20,'style':'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, w= ont it print as=0A=0A"JSON":=0A{"parentId":678,"textFieldId":111,"JSON":{'s= izeWidth':620,'text':'=93[Winning=0Athe Nobel Peace Prize]=0A','positionLef= t':20,'style':'left:20px;top:100px;width:620px;height:100px;','positionTop'= :100,'name':'','cssClass':'','objectType':'TextObject','sizeHeight':100}}= =0Awithout the quotes on the value.=0A=0APlease correct me if i got it wron= g=0A=0AI am using the json-lib-2.1 for jsd 1.5 version.=0AHaritha=0A=0A=0A= =0A----- Original Message ----=0AFrom: Andres Almiray <aal...@ya...>= =0ATo: Haritha Juturu <har...@ya...>; jso...@li...urc= eforge.net=0ASent: Tuesday, December 11, 2007 12:27:12 PM=0ASubject: Re: [j= son-lib-user] Quick Question on JSON=0A=0A=0AHi Haritha,=0A=0AAre you sure = the contents of the named property ('JSON') are not automatically converted= into a JSONObject ? it looks to me like it is a well formed json string, i= f so it should be converted automatically when you call fromObject() at top= level.=0A=0ACan you please tell us which version of Json-lib are you testi= ng with?=0A=0ARegards,=0AAndres=0A=0A----- Original Message ----=0AFrom: Ha= ritha Juturu <har...@ya...>=0ATo: jso...@li...urcefor= ge.net=0ASent: Tuesday, December 11, 2007 12:16:36 PM=0ASubject: [json-lib-= user] Quick Question on JSON=0A=0A=0AHi Everyone=0AI have a line of code=0A= JSONObject jsonObj =3D JSONObject.fromObject( textField, jsonConfig ); =0A= which produces this JSON string=0A=0A{"parentId":678,"textFieldId":111,=0A"= JSON":=0A"{'sizeWidth':620,'text':'=93[Winning the Nobel Peace Prize]','pos= itionLeft':20,'style':'left:20px;top:100px;width:620px;height:100px;','posi= tionTop':100,'name':'','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:2= 0px;top:100px;width:620px;height:100px;','positionTop':100,'name':'','cssCl= ass':'','objectType':'TextObject','sizeHeight':100}"=0A=0Ato be converted t= o a json object .... is there any API methods i can use.i am unable to loca= te any.=0A=0Ai.e my output should look like =0A{"parentId":678,"textFieldI= d":111,=0A"JSON": this value is not a string anymore=0A{'sizeWidth':620,'te= xt':'=93[Winning=0Athe Nobel Peace=0APrize]','positionLeft':20,'style':'lef= t:20px;top:100px;width:620px;height:100px;','positionTop':100,'name':'','cs= sClass':'','objectType':'TextObject','sizeHeight':100}=0A}=0A=0AI have a co= nstraint 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 =0A= know-it-all with Yahoo! Mobile. Try it now.=0A=0A=0A=0A=0A=0A Be a be= tter friend, newshound, and =0Aknow-it-all with Yahoo! Mobile. Try it now.= =0A=0A=0A=0A=0A=0A Looking for last minute shopping deals? =0AFind th= em fast with Yahoo! Search.=0A=0A=0A=0A=0A=0A=0A=0A=0A Never miss a th= ing. Make Yahoo your homepage.=0A=0A=0A=0A=0A=0A=0A=0A _____________= _______________________________________________________________________=0AB= e a better friend, newshound, and =0Aknow-it-all with Yahoo! Mobile. Try i= t now. http://mobile.yahoo.com/;_ylt=3DAhu06i62sR8HDtDypao8Wcj9tAcJ =0A |
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 |
From: Haritha J. <har...@ya...> - 2007-12-11 21:00:06
|
Hi Andres=0A=0AThe TextField bean looks like this=0Apublic class TextField(= ){ =0A private Long parentId;=0A private Long textFieldId;=0A priva= te String JSON;=0A}=0A=0AAfter executing the code JSONObject jsonObj =3D JS= ONObject.fromObject( textField, jsonConfig ); , i try to print this object= 'jsonObj" and it prints the name value pair( of JSON Property) with quotes= =0A=0A{"parentId":678,"textFieldId":111,"JSON":"{'sizeWidth':620,'text':'= =93[Winning the Nobel Peace Prize] ','positionLeft':20,'style':'left:20px;t= op: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 print as=0A=0A"JSON"= :=0A{"parentId":678,"textFieldId":111,"JSON":{'sizeWidth':620,'text':'=93[W= inning=0Athe Nobel Peace Prize]=0A','positionLeft':20,'style':'left:20px;to= p:100px;width:620px;height:100px;','positionTop':100,'name':'','cssClass':'= ','objectType':'TextObject','sizeHeight':100}}=0Awithout the quotes on the = value.=0A=0APlease correct me if i got it wrong=0A=0AI am using the json-li= b-2.1 for jsd 1.5 version.=0AHaritha=0A=0A=0A=0A----- Original Message ----= =0AFrom: Andres Almiray <aal...@ya...>=0ATo: Haritha Juturu <haritha.= ju...@ya...>; jso...@li...=0ASent: Tuesday, Dec= ember 11, 2007 12:27:12 PM=0ASubject: Re: [json-lib-user] Quick Question on= JSON=0A=0A=0AHi Haritha,=0A=0AAre you sure the contents of the named prope= rty ('JSON') are not automatically converted into a JSONObject ? it looks t= o me like it is a well formed json string, if so it should be converted aut= omatically when you call fromObject() at top level.=0A=0ACan you please tel= l us which version of Json-lib are you testing with?=0A=0ARegards,=0AAndres= =0A=0A----- Original Message ----=0AFrom: Haritha Juturu <haritha.juturu@ya= hoo.com>=0ATo: jso...@li...=0ASent: Tuesday, Decembe= r 11, 2007 12:16:36 PM=0ASubject: [json-lib-user] Quick Question on JSON=0A= =0A=0AHi Everyone=0AI have a line of code=0AJSONObject jsonObj =3D JSONObje= ct.fromObject( textField, jsonConfig ); =0Awhich produces this JSON string= =0A=0A{"parentId":678,"textFieldId":111,=0A"JSON":=0A"{'sizeWidth':620,'tex= t':'=93[Winning the Nobel Peace Prize]','positionLeft':20,'style':'left:20p= x;top:100px;width:620px;height:100px;','positionTop':100,'name':'','cssClas= s':'','objectType':'TextObject','sizeHeight':100}"=0A}=0A=0Anow if i want t= he property "json" whose value is a string=0A =93[Winning the Nobel Peace= =0APrize]','positionLeft':20,'style':'left:20px;top:100px;width:620px;heigh= t:100px;','positionTop':100,'name':'','cssClass':'','objectType':'TextObjec= t','sizeHeight':100}"=0A=0Ato be converted to a json object .... is there a= ny API methods i can use.i am unable to locate any.=0A=0Ai.e my output sho= uld look like =0A{"parentId":678,"textFieldId":111,=0A"JSON": this value is= not a string anymore=0A{'sizeWidth':620,'text':'=93[Winning=0Athe Nobel Pe= ace=0APrize]','positionLeft':20,'style':'left:20px;top:100px;width:620px;he= ight:100px;','positionTop':100,'name':'','cssClass':'','objectType':'TextOb= ject','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, newshound, and =0Akn= ow-it-all with Yahoo! Mobile. Try it now.=0A=0A=0A=0A=0A=0A _________= ___________________________________________________________________________= =0ANever miss a thing. Make Yahoo your home page. =0Ahttp://www.yahoo.com/= r/hs |
From: Andres A. <aal...@ya...> - 2007-12-11 20:27:18
|
Hi Haritha,=0A=0AAre you sure the contents of the named property ('JSON') a= re not automatically converted into a JSONObject ? it looks to me like it i= s a well formed json string, if so it should be converted automatically whe= n you call fromObject() at top level.=0A=0ACan you please tell us which ver= sion of Json-lib are you testing with?=0A=0ARegards,=0AAndres=0A=0A----- Or= iginal Message ----=0AFrom: Haritha Juturu <har...@ya...>=0ATo:= jso...@li...=0ASent: Tuesday, December 11, 2007 12:= 16:36 PM=0ASubject: [json-lib-user] Quick Question on JSON=0A=0A=0AHi Every= one=0AI have a line of code=0AJSONObject jsonObj =3D JSONObject.fromObject(= textField, jsonConfig ); =0Awhich produces this JSON string=0A=0A{"parent= Id":678,"textFieldId":111,=0A"JSON":=0A"{'sizeWidth':620,'text':'=93[Winnin= g the Nobel Peace Prize]','positionLeft':20,'style':'left:20px;top:100px;wi= dth:620px;height:100px;','positionTop':100,'name':'','cssClass':'','objectT= ype':'TextObject','sizeHeight':100}"=0A}=0A=0Anow if i want the property "j= son" whose value is a string=0A =93[Winning the Nobel Peace=0APrize]','posi= tionLeft':20,'style':'left:20px;top:100px;width:620px;height:100px;','posit= ionTop':100,'name':'','cssClass':'','objectType':'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[Winning=0Athe Nobel Peace=0APrize]',= 'positionLeft':20,'style':'left:20px;top:100px;width:620px;height:100px;','= positionTop':100,'name':'','cssClass':'','objectType':'TextObject','sizeHei= ght':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 bette= r friend, newshound, and =0Aknow-it-all with Yahoo! Mobile. Try it now.=0A= =0A=0A=0A=0A=0A ______________________________________________________= ______________________________=0ABe a better friend, newshound, and =0Aknow= -it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=3DA= hu06i62sR8HDtDypao8Wcj9tAcJ =0A |
From: Haritha J. <har...@ya...> - 2007-12-11 20:16:43
|
Hi Everyone=0AI have a line of code=0AJSONObject jsonObj =3D JSONObject.fro= mObject( textField, jsonConfig ); =0Awhich produces this JSON string=0A=0A= {"parentId":678,"textFieldId":111,=0A"JSON":=0A"{'sizeWidth':620,'text':'= =93[Winning the Nobel Peace Prize]','positionLeft':20,'style':'left:20px;to= p:100px;width:620px;height:100px;','positionTop':100,'name':'','cssClass':'= ','objectType':'TextObject','sizeHeight':100}"=0A}=0A=0Anow if i want the p= roperty "json" whose value is a string=0A =93[Winning the Nobel Peace=0APri= ze]','positionLeft':20,'style':'left:20px;top:100px;width:620px;height:100p= x;','positionTop':100,'name':'','cssClass':'','objectType':'TextObject','si= zeHeight':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 lo= ok like =0A{"parentId":678,"textFieldId":111,=0A"JSON": this value is not a= string anymore=0A{'sizeWidth':620,'text':'=93[Winning=0Athe Nobel Peace=0A= Prize]','positionLeft':20,'style':'left:20px;top:100px;width:620px;height:1= 00px;','positionTop':100,'name':'','cssClass':'','objectType':'TextObject',= 'sizeHeight':100}=0A}=0A=0AI have a constraint that i need to do this manip= ulation on the jsonObj .=0A=0AThanks=0AHaritha=0A=0A=0A=0A=0A=0A=0A __= ___________________________________________________________________________= _______=0ALooking for last minute shopping deals? =0AFind them fast with Y= ahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?categor= y=3Dshopping |