json-lib-user Mailing List for Json-lib (Page 5)
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: Christopher H. <hu...@in...> - 2008-07-05 22:56:30
|
Hi Andres, By way of closure to this thread I'm now using a bean processor and all is well. Thanks for your help. Cheers, -C |
From: Andres A. <aal...@ya...> - 2008-06-29 19:04:06
|
Hi Christopher, Yes, please feel free to grab a copy from the cvs repo and test it (you'll need maven+ant to build the package). Further review on how the code works with filters, it is impossible to move the filters from their current place, as they also require the property's value. If no read method is available for the property then the value can't be retrieved. There are two other options at your disposal: 1) JsonConfig.setExcludes() 2) register a JsonBeanProcessor #1 is the most straightforward and less intrusive. The exclusion list does not discriminate using the source class, only the matching property name. #2 requires you to provided the full serialization of the target class. It is a bit less intrusive that having the target class implement JSONString. I recommend you to go with option #1 to filter out unwanted properties of Geometry that the filtered mechanism can't touch. 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: Christopher Hunt <hu...@in...> To: Andres Almiray <aal...@ya...> Cc: jso...@li... Sent: Sunday, June 29, 2008 12:16:54 AM Subject: Re: [json-lib-user] What causes: Property 'x' has no read method. SKIPPED? Wonderful! Thanks. Shall I download from the source repository, build and test? Cheers, -C On 29/06/2008, at 5:00 PM, Andres Almiray wrote: Hi Christopher, It looks to me that your filter is configured to filter out every single property of a Geometry class/subclass unless its name is 'coordinates' or 'SRID', still it tries to process other properties? Ahh I see JSONObject:737, the filter is applied only if the property has a read method. Let me see if it can be changed. Btw, filed 2005661 Add class name to skipped properties messages and fixed it already. 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: Christopher Hunt <hu...@in...> To: Andres Almiray <aal...@ya...> Cc: jso...@li... Sent: Saturday, June 28, 2008 11:46:45 PM Subject: Re: [json-lib-user] What causes: Property 'x' has no read method. SKIPPED? Hi Andres, Thanks for your email. My reply: Json-lib relies on PropertyDescriptors to find which properties may be serialized into JSON. In your case there is a class that has a write-only property name geometryN (usually it just has a setter method).I think it is a read-only property... Here's the class reference: http://www.vividsolutions.com/jts/javadoc/com/vividsolutions/jts/geom/Geometry.html Perhaps the property descriptor for 'geometryN' is actually for an indexed property and not a regular one.Yes it is. Without a proper bounded limit for that indexed property it may be hard to retrieve any values. I agree that the message is not quite clear on which class is the owner of that property, I'll fix that for the next release. Let me think what can be done with indexed properties, you can tweak the serialization process with JsonValueProcessors or JsonBeanProcessors for the time being.OK. Thanks. I understand the work-around - but I'm still not clear on why the warning appears when I've told JSON to filter my Geometry instances... Perhaps my filter is wrong? Cheers, -C |
From: Christopher H. <hu...@in...> - 2008-06-29 07:16:59
|
Wonderful! Thanks. Shall I download from the source repository, build and test? Cheers, -C On 29/06/2008, at 5:00 PM, Andres Almiray wrote: > Hi Christopher, > > It looks to me that your filter is configured to filter out every > single property of a Geometry class/subclass unless its name is > 'coordinates' or 'SRID', still it tries to process other properties? > > Ahh I see JSONObject:737, the filter is applied only if the property > has a read method. Let me see if it can be changed. > Btw, filed 2005661 Add class name to skipped properties messages and > fixed it already. > > 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: Christopher Hunt <hu...@in...> > To: Andres Almiray <aal...@ya...> > Cc: jso...@li... > Sent: Saturday, June 28, 2008 11:46:45 PM > Subject: Re: [json-lib-user] What causes: Property 'x' has no read > method. SKIPPED? > > Hi Andres, > > Thanks for your email. My reply: > >> Json-lib relies on PropertyDescriptors to find which properties may >> be serialized into JSON. >> In your case there is a class that has a write-only property name >> geometryN (usually it just >> has a setter method). > I think it is a read-only property... Here's the class reference: > > http://www.vividsolutions.com/jts/javadoc/com/vividsolutions/jts/geom/Geometry.html > >> Perhaps the property descriptor for 'geometryN' is actually for an >> indexed >> property and not a regular one. > Yes it is. > >> Without a proper bounded limit for that indexed property it may >> be hard to retrieve any values. >> >> I agree that the message is not quite clear on which class is the >> owner of that property, I'll fix that >> for the next release. Let me think what can be done with indexed >> properties, you can tweak the >> serialization process with JsonValueProcessors or >> JsonBeanProcessors for the time being. > OK. Thanks. I understand the work-around - but I'm still not clear > on why the warning appears when I've told JSON to filter my Geometry > instances... Perhaps my filter is wrong? > > Cheers, > -C > > |
From: Andres A. <aal...@ya...> - 2008-06-29 07:00:16
|
Hi Christopher, It looks to me that your filter is configured to filter out every single property of a Geometry class/subclass unless its name is 'coordinates' or 'SRID', still it tries to process other properties? Ahh I see JSONObject:737, the filter is applied only if the property has a read method. Let me see if it can be changed. Btw, filed 2005661 Add class name to skipped properties messages and fixed it already. 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: Christopher Hunt <hu...@in...> To: Andres Almiray <aal...@ya...> Cc: jso...@li... Sent: Saturday, June 28, 2008 11:46:45 PM Subject: Re: [json-lib-user] What causes: Property 'x' has no read method. SKIPPED? Hi Andres, Thanks for your email. My reply: Json-lib relies on PropertyDescriptors to find which properties may be serialized into JSON. In your case there is a class that has a write-only property name geometryN (usually it just has a setter method). I think it is a read-only property... Here's the class reference: http://www.vividsolutions.com/jts/javadoc/com/vividsolutions/jts/geom/Geometry.html Perhaps the property descriptor for 'geometryN' is actually for an indexed property and not a regular one. Yes it is. Without a proper bounded limit for that indexed property it may be hard to retrieve any values. I agree that the message is not quite clear on which class is the owner of that property, I'll fix that for the next release. Let me think what can be done with indexed properties, you can tweak the serialization process with JsonValueProcessors or JsonBeanProcessors for the time being.OK. Thanks. I understand the work-around - but I'm still not clear on why the warning appears when I've told JSON to filter my Geometry instances... Perhaps my filter is wrong? Cheers, -C |
From: Christopher H. <hu...@in...> - 2008-06-29 06:46:50
|
Hi Andres, Thanks for your email. My reply: > Json-lib relies on PropertyDescriptors to find which properties may > be serialized into JSON. > In your case there is a class that has a write-only property name > geometryN (usually it just > has a setter method). I think it is a read-only property... Here's the class reference: http://www.vividsolutions.com/jts/javadoc/com/vividsolutions/jts/geom/Geometry.html > Perhaps the property descriptor for 'geometryN' is actually for an > indexed > property and not a regular one. Yes it is. > Without a proper bounded limit for that indexed property it may > be hard to retrieve any values. > > I agree that the message is not quite clear on which class is the > owner of that property, I'll fix that > for the next release. Let me think what can be done with indexed > properties, you can tweak the > serialization process with JsonValueProcessors or JsonBeanProcessors > for the time being. OK. Thanks. I understand the work-around - but I'm still not clear on why the warning appears when I've told JSON to filter my Geometry instances... Perhaps my filter is wrong? Cheers, -C |
From: Andres A. <aal...@ya...> - 2008-06-29 06:23:59
|
Hi Christopher, Json-lib relies on PropertyDescriptors to find which properties may be serialized into JSON. In your case there is a class that has a write-only property name geometryN (usually it just has a setter method). Perhaps the property descriptor for 'geometryN' is actually for an indexed property and not a regular one. Without a proper bounded limit for that indexed property it may be hard to retrieve any values. I agree that the message is not quite clear on which class is the owner of that property, I'll fix that for the next release. Let me think what can be done with indexed properties, you can tweak the serialization process with JsonValueProcessors or JsonBeanProcessors for the time being. 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: Christopher Hunt <hu...@in...> To: jso...@li... Sent: Saturday, June 28, 2008 10:55:34 PM Subject: [json-lib-user] What causes: Property 'x' has no read method. SKIPPED? Hi there, Thanks for providing JSON-LIB. I think that it is great. I have received the following warning in my logs: WARN 2008-06-29 14:30:20,999 [connector.stdio.0.dispatcher.1] net.sf.json.JSONObject: Property 'geometryN' has no read method. SKIPPED Can you please shed some more light on what conditions cause the message to appear? Additionally is there a means to determine the class that is actually causing the problem? I'm using the Java Topology Suite and can only see two instances of its Geometry type in my code (there is a public getGeometryN(int n) method associated with the Geometry class). I also have the following setup for JSON-LIB which really should capture Geometry conversions: JsonConfig jsonConfig = new JsonConfig(); jsonConfig.registerJsonValueProcessor(Coordinate.class, new JsonValueProcessor() { public Object processArrayValue(Object arg0, JsonConfig arg1) { Coordinate coord = (Coordinate) arg0; return "{x:" + coord.x + ",y:" + coord.y + ",z:" + coord.z + "}"; } public Object processObjectValue(String arg0, Object arg1, JsonConfig arg2) { return processArrayValue(arg1, arg2); } }); jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.NOPROP); jsonConfig.setJsonPropertyFilter(new PropertyFilter() { public boolean apply(Object source, String name, Object value) { boolean filterOut = false; if (source instanceof Geometry) { filterOut = (!name.equals("coordinates") && !name .equals("SRID")); } return filterOut; } }); JSONObject jsonObject = JSONObject.fromObject(this, jsonConfig); return jsonObject.toString(); Help is appreciated. Cheers, -C ------------------------------------------------------------------------- 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 |
From: Christopher H. <hu...@in...> - 2008-06-29 05:55:42
|
Hi there, Thanks for providing JSON-LIB. I think that it is great. I have received the following warning in my logs: WARN 2008-06-29 14:30:20,999 [connector.stdio.0.dispatcher.1] net.sf.json.JSONObject: Property 'geometryN' has no read method. SKIPPED Can you please shed some more light on what conditions cause the message to appear? Additionally is there a means to determine the class that is actually causing the problem? I'm using the Java Topology Suite and can only see two instances of its Geometry type in my code (there is a public getGeometryN(int n) method associated with the Geometry class). I also have the following setup for JSON-LIB which really should capture Geometry conversions: JsonConfig jsonConfig = new JsonConfig(); jsonConfig.registerJsonValueProcessor(Coordinate.class, new JsonValueProcessor() { public Object processArrayValue(Object arg0, JsonConfig arg1) { Coordinate coord = (Coordinate) arg0; return "{x:" + coord.x + ",y:" + coord.y + ",z:" + coord.z + "}"; } public Object processObjectValue(String arg0, Object arg1, JsonConfig arg2) { return processArrayValue(arg1, arg2); } }); jsonConfig.setCycleDetectionStrategy(CycleDetectionStrategy.NOPROP); jsonConfig.setJsonPropertyFilter(new PropertyFilter() { public boolean apply(Object source, String name, Object value) { boolean filterOut = false; if (source instanceof Geometry) { filterOut = (!name.equals("coordinates") && !name .equals("SRID")); } return filterOut; } }); JSONObject jsonObject = JSONObject.fromObject(this, jsonConfig); return jsonObject.toString(); Help is appreciated. Cheers, -C |
From: Haritha J. <har...@ya...> - 2008-06-25 20:34:11
|
Hey Andres I changed to the latest Json-lib jar (i.e json-lib-2.2.2-jdk15.jar) and it worked. I was using an older version json-lib-2.2-jdk15.jar. Thanks for your help --Haritha ----- Original Message ---- From: Andres Almiray <aal...@ya...> To: Haritha Juturu <har...@ya...>; jso...@li... Sent: Wednesday, June 25, 2008 12:46:58 PM Subject: Re: Converting JSONSerializer.toJSON Hi Haritha, Since the 2.x series JSONObject switched from HashMap to a ListOrderedMap (commons-collections) , there is even a test to assure this behavior should not be broken 371 public void testFR_1858073_preserveInsertionOrder() { 372 JSONObject jsonObject = new JSONObject().element( "one", "one" ).element( "two", "two" ) 373 .element( "three", "three" ); 374 JSONArray actual = jsonObject.names(); 375 JSONArray expected = new JSONArray().element( "one" ).element( "two" ).element( "three" ); 376 Assertions.assertEquals( expected, actual ); 377 } Perhaps you stumbled into a case that was not considered by the current impl. May I ask which version of Json-lib are you testing with? ------------------------------------------- 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...; aal...@ya... Sent: Wednesday, June 25, 2008 12:07:19 PM Subject: Converting JSONSerializer.toJSON Hi All/Andres I have a LinkedHashMap allPhotos = new LinkedHashMap<String, Object>(); which has objects sorted in order of insertion. What i am trying to do is convert this to a JSON string by using the following code JSONObject json = (JSONObject) JSONSerializer.toJSON( allPhotos ); json.toString(); When i do this the JSON that is created looses the order of the elements in allPhotos. Example I put data in this order allPhotos.put('abc','david'); allPhotos.put('cdg','jason'); allPhotos.put('efg','brian'); But my final json string looks like this {"cdg":"jason","efg":"brian","abc":"david"} Retaining this order is important to our application. Can anyone tell me how i can achieve that? Thanks Haritha |
From: Andres A. <aal...@ya...> - 2008-06-25 19:49:24
|
Hi Haritha, jsonConfig.setRootClass() only makes sense when you are converting from JSON to Java (by calling toBean/toList/toArray/toJava in the proper classes). Please make sure you are testing with the latest stable release (2.2.2), if the problem persists then we have a bug. ------------------------------------------- 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...; aal...@ya... Sent: Wednesday, June 25, 2008 12:33:15 PM Subject: Fw: [json-lib-user] Converting JSONSerializer.toJSON Hi All As an update to my previous query I have even tried LinkedHashMap allPhotos = new LinkedHashMap<String, Object>(); JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setRootClass(LinkedHashMap.class); json = JSONObject.fromObject(allPhotos,jsonConfig); json.toString(); but it gives me the same result. Is there a way to get the JSON string in the same order. Haritha ----- Forwarded Message ---- From: Haritha Juturu <har...@ya...> To: jso...@li...; aal...@ya... Sent: Wednesday, June 25, 2008 12:07:19 PM Subject: [json-lib-user] Converting JSONSerializer.toJSON Hi All/Andres I have a LinkedHashMap allPhotos = new LinkedHashMap<String, Object>(); which has objects sorted in order of insertion. What i am trying to do is convert this to a JSON string by using the following code JSONObject json = (JSONObject) JSONSerializer.toJSON( allPhotos ); json.toString(); When i do this the JSON that is created looses the order of the elements in allPhotos. Example I put data in this order allPhotos.put('abc','david'); allPhotos.put('cdg','jason'); allPhotos.put('efg','brian'); But my final json string looks like this {"cdg":"jason","efg":"brian","abc":"david"} Retaining this order is important to our application. Can anyone tell me how i can achieve that? Thanks Haritha |
From: Andres A. <aal...@ya...> - 2008-06-25 19:47:07
|
Hi Haritha, Since the 2.x series JSONObject switched from HashMap to a ListOrderedMap (commons-collections) , there is even a test to assure this behavior should not be broken 371 public void testFR_1858073_preserveInsertionOrder() { 372 JSONObject jsonObject = new JSONObject().element( "one", "one" ).element( "two", "two" ) 373 .element( "three", "three" ); 374 JSONArray actual = jsonObject.names(); 375 JSONArray expected = new JSONArray().element( "one" ).element( "two" ).element( "three" ); 376 Assertions.assertEquals( expected, actual ); 377 } Perhaps you stumbled into a case that was not considered by the current impl. May I ask which version of Json-lib are you testing with? ------------------------------------------- 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...; aal...@ya... Sent: Wednesday, June 25, 2008 12:07:19 PM Subject: Converting JSONSerializer.toJSON Hi All/Andres I have a LinkedHashMap allPhotos = new LinkedHashMap<String, Object>(); which has objects sorted in order of insertion. What i am trying to do is convert this to a JSON string by using the following code JSONObject json = (JSONObject) JSONSerializer.toJSON( allPhotos ); json.toString(); When i do this the JSON that is created looses the order of the elements in allPhotos. Example I put data in this order allPhotos.put('abc','david'); allPhotos.put('cdg','jason'); allPhotos.put('efg','brian'); But my final json string looks like this {"cdg":"jason","efg":"brian","abc":"david"} Retaining this order is important to our application. Can anyone tell me how i can achieve that? Thanks Haritha |
From: Haritha J. <har...@ya...> - 2008-06-25 19:33:22
|
------------------------------------------------------------------------- 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 |
From: Haritha J. <har...@ya...> - 2008-06-25 19:07:27
|
Hi All/Andres I have a LinkedHashMap allPhotos = new LinkedHashMap<String, Object>(); which has objects sorted in order of insertion. What i am trying to do is convert this to a JSON string by using the following code JSONObject json = (JSONObject) JSONSerializer.toJSON( allPhotos ); json.toString(); When i do this the JSON that is created looses the order of the elements in allPhotos. Example I put data in this order allPhotos.put('abc','david'); allPhotos.put('cdg','jason'); allPhotos.put('efg','brian'); But my final json string looks like this {"cdg":"jason","efg":"brian","abc":"david"} Retaining this order is important to our application. Can anyone tell me how i can achieve that? Thanks Haritha |
From: Kiril <kir...@gm...> - 2008-06-20 12:02:33
|
Hi Raymon, the problem you seem to have is not related to mine directly. However, I had something similar with dates: You cannot expect json to deserialize Date from the string you pass in your code. You will need to parse it and pass it to .toBean in the correct way. json cuts the date to integers, representing year,month,day,hour,min,sec. Also, there is a Time part, being seconds from 1970, I think. So either you need to pass the group of integers or the long with Time (and Timezone). To see the exact format just serialize your class to json. I use json to get XML at the end, so here is how a Date looks (note that month is zero based): <date> <date>3</date> <day>2</day> <hours>16</hours> <minutes>26</minutes> <month>5</month> <seconds>29</seconds> <time>1212524789781</time> <timezoneOffset>240</timezoneOffset> <year>108</year> </date> Also, for each embedded class other than simple types, register a Morpher (In the example, Field is member of Filter): JSONUtils.getMorpherRegistry().registerMorpher(new EnumMorpher(Field.class)); Then, deserialize this way: JSONObject jsonObject = new JSONObject(); JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setRootClass(Filter.class); jsonConfig.setIgnoreDefaultExcludes(false); jsonConfig.setExcludes(new String[] {"class"}); //exclude the class 'member'; jsonObject = (JSONObject)JSONSerializer.toJSON(jsonString); this.filter =(Filter)JSONSerializer.toJava(jsonObject, jsonConfig); Then for each member bean, get specific Morpher: Morpher fieldMorpher = new BeanMorpher( Field.class, morpherRegistry); morpherRegistry.registerMorpher(fieldMorpher); Iterate your member objects ( I have an array of them) and cast to specific type: List<Field> fields = new ArrayList<Field>(); for( Iterator ii = filter.getFields().iterator(); ii.hasNext(); Field field = (Field)morpherRegistry.morph(Field.class, ii.next()); fields.add(field); } filter.setFields(fields); I hope this helps! Let me know if I can assist further. Cheers, Kiril. On Fri, Jun 20, 2008 at 3:55 AM, Raymon Wang <rm...@gm...> wrote: > Hi, Kiril > > I got your email address from json-lib mailing-list,and knew that you > have successed in conversion with a Date class. > > > would you please help me with the problem at link of > http://groups.google.com/group/json-schema/t/e27e589ac440679e? > > Thanks in advance! > > |
From: Kiril <kir...@gm...> - 2008-06-14 00:07:05
|
Hi again, I figured out the problem with the XMLSerializer, but now I have the same issue with JSONSerializer. The code is pretty simple (may be this is the problem?:)): JSONObject jsonObject = new JSONObject(); jsonObject = (JSONObject)JSONSerializer.toJSON(item); return jsonObject.toString(3); item has some member strings with unicode/utf-8 encoding. I examined the jsonObject and saw that the unicode values are preserved. The problem appears to be with the toString() method - I seem to get plain ASCII at this point... Many thanks in advance! Kiril. On Wed, Jun 11, 2008 at 2:22 AM, Andres Almiray <aal...@ya...> wrote: > Hi Kirill, > > In theory Json-lib shouldn't have any trouble at all handling unicode > strings. > Regarding the XMLSerializer, did you try setting a particular encoding with > xmlSerializer.write( json, encoding ) ? > > Cheers, > Andres > > > > ----- Original Message ---- > From: Kiril <kir...@gm...> > To: jso...@li... > Sent: Tuesday, June 10, 2008 10:31:14 PM > Subject: [json-lib-user] json-lib and Unicode > > Hi all, > > I have classes that serialize Ok to json, but how should I handle Unicode > strings? > Is there any special pre-processing that needs to be done? > > Also, using XMLSerializer().write(json) returns an XML which is not encoded > properly as Unicode, thought the <?xml... instruction sets UTF-8 encoding. > > Thanks in advance, > > Kiril. > > |
From: Andres A. <aal...@ya...> - 2008-06-11 06:23:01
|
Hi Kirill, In theory Json-lib shouldn't have any trouble at all handling unicode strings. Regarding the XMLSerializer, did you try setting a particular encoding with xmlSerializer.write( json, encoding ) ? Cheers, Andres ----- Original Message ---- From: Kiril <kir...@gm...> To: jso...@li... Sent: Tuesday, June 10, 2008 10:31:14 PM Subject: [json-lib-user] json-lib and Unicode Hi all, I have classes that serialize Ok to json, but how should I handle Unicode strings? Is there any special pre-processing that needs to be done? Also, using XMLSerializer().write(json) returns an XML which is not encoded properly as Unicode, thought the <?xml... instruction sets UTF-8 encoding. Thanks in advance, Kiril. |
From: Kiril <kir...@gm...> - 2008-06-11 05:31:16
|
Hi all, I have classes that serialize Ok to json, but how should I handle Unicode strings? Is there any special pre-processing that needs to be done? Also, using XMLSerializer().write(json) returns an XML which is not encoded properly as Unicode, thought the <?xml... instruction sets UTF-8 encoding. Thanks in advance, Kiril. |
From: Andres A. <aal...@ya...> - 2008-06-11 05:09:14
|
What about this (pseudo) Java code ;-) class Bean { String name } class BeanFactory { Bean newBean( String name ){ new Bean(name: name) } } class MyNewBeanInstanceFactory extends NewBeanInstanceFactory.DEFAULT { BeanFactory factory = new BeanFactory() public Object newInstance( Class target, JSONObject source ){ if( Bean.class.isAssignableFrom(target) ) { return factory.newBean( source.get("name") ) }else{ super.newInstance(target,source) } } } JsonConfig jsonConfig = new JsonConfig() jsonConfig.setNewBeanInstanceStrategy( new MyNewBeanInstanceFactory() ) ... ----- Original Message ---- From: Darlene Wong <dar...@gm...> To: Andres Almiray <aal...@ya...> Cc: jso...@li... Sent: Tuesday, June 10, 2008 6:52:27 PM Subject: Re: [json-lib-user] Converting GregorianCalendar object, Java to JSON and back Thanks Andres. I will give this a shot. Can you point me to some sample code that creates a custom strategy? thanks, Darlene On Fri, Jun 6, 2008 at 4:15 PM, Andres Almiray <aal...@ya...> wrote: Hi Darlene, There is indeed a restriction on the classes that can be used when serializing back to Java, they must adhere to the JavaBeans conventions (no-arg constructor, getters/setters, etc). It looks like GregorianCalendar follows suit still it throws an exception. Well no worries as you may register a NewBeanInstanceStrategy with JsonConfig. The default strategy follows the JavaBeans convention (no-arg constructor), with a custom strategy you are free to instantiate the class as you see fit, for example using a factory. http://json-lib.sourceforge.net/xref/net/sf/json/util/NewBeanInstanceStrategy.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. ----- Original Message ---- From: Darlene Wong <dar...@gm...> To: jso...@li... Sent: Friday, June 6, 2008 3:08:30 PM Subject: [json-lib-user] Converting GregorianCalendar object, Java to JSON and back Hi, I'm new to json-lib. I want to convert a Java class into JSONObject and then back again. I am able to do this conversion with a Date class. However, the class I want to convert contains a nested XMLGregorianCalendar object, which has issues when converting from JSONObject to Java. I've tried to create a simple test case that converts only a GregorianCalendar object (http://java.sun.com/javase/6/docs/api/java/util/GregorianCalendar.html). This works fine when converting from Java to JSONObject, but the reverse conversion gives an InstantiationException error when calling toJava(). Here is my sample code: GregorianCalendar gc = DateUtil.getCalendar(-7); System.out.println(gc.toString()); // Convert object to JSON JSONObject jsonObject = (JSONObject) JSONSerializer.toJSON(gc); System.out.println(jsonObject.toString()); // Convert JSON object back into Java object GregorianCalendar gc2; JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setRootClass(GregorianCalendar.class); gc2 = (GregorianCalendar) JSONSerializer.toJava(jsonObject, jsonConfig); System.out.println(gc2.toString()); The output is as follows: java.util.GregorianCalendar[time=1212788878236,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=java.util.SimpleTimeZone[id=GMT-07:00,offset=-25200000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=3,startDay=1,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=7200000,endTimeMode=0],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2008,MONTH=5,WEEK_OF_YEAR=23,WEEK_OF_MONTH=1,DAY_OF_MONTH=6,DAY_OF_YEAR=158,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=3,HOUR_OF_DAY=15,MINUTE=47,SECOND=58,MILLISECOND=236,ZONE_OFFSET=-25200000,DST_OFFSET=3600000] {"firstDayOfWeek":1,"gregorianChange":{"date":4,"day":4,"hours":16,"minutes":0,"month":9,"seconds":0,"time":-12219292800000,"timezoneOffset":480,"year":-318},"lenient":true,"minimalDaysInFirstWeek":1,"time":{"date":6,"day":5,"hours":14,"minutes":47,"month":5,"seconds":58,"time":1212788878236,"timezoneOffset":420,"year":108},"timeInMillis":1212788878236,"timeZone":{"DSTSavings":3600000,"ID":"GMT-07:00","displayName":"GMT-07:00","rawOffset":-25200000}} net.sf.json.JSONException: java.lang.InstantiationException at net.sf.json.JSONObject.toBean(JSONObject.java:304) at net.sf.json.JSONObject.toBean(JSONObject.java:420) at net.sf.json.JSONSerializer.toJava(JSONSerializer.java:69) ... Like I said, I am able to get the same code to work on other objects, such as Date objects, so what am I missing? Is there a limitation on the types of objects that can be converted to JSONObject and back? Any help or pointers is greatly appreciated! Darlene |
From: Darlene W. <dar...@gm...> - 2008-06-11 01:52:31
|
Thanks Andres. I will give this a shot. Can you point me to some sample code that creates a custom strategy? thanks, Darlene On Fri, Jun 6, 2008 at 4:15 PM, Andres Almiray <aal...@ya...> wrote: > Hi Darlene, > > There is indeed a restriction on the classes that can be used when > serializing back to Java, they must adhere to the JavaBeans conventions > (no-arg constructor, getters/setters, etc). It looks like GregorianCalendar > follows suit still it throws an exception. Well no worries as you may > register a NewBeanInstanceStrategy with JsonConfig. The default strategy > follows the JavaBeans convention (no-arg constructor), with a custom > strategy you are free to instantiate the class as you see fit, for example > using a factory. > > > http://json-lib.sourceforge.net/xref/net/sf/json/util/NewBeanInstanceStrategy.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. > > > ----- Original Message ---- > From: Darlene Wong <dar...@gm...> > To: jso...@li... > Sent: Friday, June 6, 2008 3:08:30 PM > Subject: [json-lib-user] Converting GregorianCalendar object, Java to JSON > and back > > Hi, I'm new to json-lib. I want to convert a Java class into JSONObject > and then back again. I am able to do this conversion with a Date class. > However, the class I want to convert contains a nested XMLGregorianCalendar > object, which has issues when converting from JSONObject to Java. > > I've tried to create a simple test case that converts only a > GregorianCalendar object ( > http://java.sun.com/javase/6/docs/api/java/util/GregorianCalendar.html). > This works fine when converting from Java to JSONObject, but the reverse > conversion gives an InstantiationException error when calling toJava(). > Here is my sample code: > > > GregorianCalendar gc = DateUtil.getCalendar(-7); > System.out.println(gc.toString()); > > // Convert object to JSON > JSONObject jsonObject = (JSONObject) JSONSerializer.toJSON(gc); > System.out.println(jsonObject.toString()); > > > // Convert JSON object back into Java object > GregorianCalendar gc2; > JsonConfig jsonConfig = new JsonConfig(); > jsonConfig.setRootClass(GregorianCalendar.class); > gc2 = (GregorianCalendar) JSONSerializer.toJava(jsonObject, > jsonConfig); > System.out.println(gc2.toString()); > > > The output is as follows: > > java.util.GregorianCalendar[time=1212788878236,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=java.util.SimpleTimeZone[id=GMT-07:00,offset=-25200000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=3,startDay=1,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=7200000,endTimeMode=0],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2008,MONTH=5,WEEK_OF_YEAR=23,WEEK_OF_MONTH=1,DAY_OF_MONTH=6,DAY_OF_YEAR=158,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=3,HOUR_OF_DAY=15,MINUTE=47,SECOND=58,MILLISECOND=236,ZONE_OFFSET=-25200000,DST_OFFSET=3600000] > > {"firstDayOfWeek":1,"gregorianChange":{"date":4,"day":4,"hours":16,"minutes":0,"month":9,"seconds":0,"time":-12219292800000,"timezoneOffset":480,"year":-318},"lenient":true,"minimalDaysInFirstWeek":1,"time":{"date":6,"day":5,"hours":14,"minutes":47,"month":5,"seconds":58,"time":1212788878236,"timezoneOffset":420,"year":108},"timeInMillis":1212788878236,"timeZone":{"DSTSavings":3600000,"ID":"GMT-07:00","displayName":"GMT-07:00","rawOffset":-25200000}} > net.sf.json.JSONException: java.lang.InstantiationException > at net.sf.json.JSONObject.toBean(JSONObject.java:304) > at net.sf.json.JSONObject.toBean(JSONObject.java:420) > at net.sf.json.JSONSerializer.toJava(JSONSerializer.java:69) > > ... > > Like I said, I am able to get the same code to work on other objects, such > as Date objects, so what am I missing? Is there a limitation on the types > of objects that can be converted to JSONObject and back? > > Any help or pointers is greatly appreciated! > > Darlene > > |
From: Andres A. <aal...@ya...> - 2008-06-06 23:15:25
|
Hi Darlene, There is indeed a restriction on the classes that can be used when serializing back to Java, they must adhere to the JavaBeans conventions (no-arg constructor, getters/setters, etc). It looks like GregorianCalendar follows suit still it throws an exception. Well no worries as you may register a NewBeanInstanceStrategy with JsonConfig. The default strategy follows the JavaBeans convention (no-arg constructor), with a custom strategy you are free to instantiate the class as you see fit, for example using a factory. http://json-lib.sourceforge.net/xref/net/sf/json/util/NewBeanInstanceStrategy.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. ----- Original Message ---- From: Darlene Wong <dar...@gm...> To: jso...@li... Sent: Friday, June 6, 2008 3:08:30 PM Subject: [json-lib-user] Converting GregorianCalendar object, Java to JSON and back Hi, I'm new to json-lib. I want to convert a Java class into JSONObject and then back again. I am able to do this conversion with a Date class. However, the class I want to convert contains a nested XMLGregorianCalendar object, which has issues when converting from JSONObject to Java. I've tried to create a simple test case that converts only a GregorianCalendar object (http://java.sun.com/javase/6/docs/api/java/util/GregorianCalendar.html). This works fine when converting from Java to JSONObject, but the reverse conversion gives an InstantiationException error when calling toJava(). Here is my sample code: GregorianCalendar gc = DateUtil.getCalendar(-7); System.out.println(gc.toString()); // Convert object to JSON JSONObject jsonObject = (JSONObject) JSONSerializer.toJSON(gc); System.out.println(jsonObject.toString()); // Convert JSON object back into Java object GregorianCalendar gc2; JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setRootClass(GregorianCalendar.class); gc2 = (GregorianCalendar) JSONSerializer.toJava(jsonObject, jsonConfig); System.out.println(gc2.toString()); The output is as follows: java.util.GregorianCalendar[time=1212788878236,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=java.util.SimpleTimeZone[id=GMT-07:00,offset=-25200000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=3,startDay=1,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=7200000,endTimeMode=0],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2008,MONTH=5,WEEK_OF_YEAR=23,WEEK_OF_MONTH=1,DAY_OF_MONTH=6,DAY_OF_YEAR=158,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=3,HOUR_OF_DAY=15,MINUTE=47,SECOND=58,MILLISECOND=236,ZONE_OFFSET=-25200000,DST_OFFSET=3600000] {"firstDayOfWeek":1,"gregorianChange":{"date":4,"day":4,"hours":16,"minutes":0,"month":9,"seconds":0,"time":-12219292800000,"timezoneOffset":480,"year":-318},"lenient":true,"minimalDaysInFirstWeek":1,"time":{"date":6,"day":5,"hours":14,"minutes":47,"month":5,"seconds":58,"time":1212788878236,"timezoneOffset":420,"year":108},"timeInMillis":1212788878236,"timeZone":{"DSTSavings":3600000,"ID":"GMT-07:00","displayName":"GMT-07:00","rawOffset":-25200000}} net.sf.json.JSONException: java.lang.InstantiationException at net.sf.json.JSONObject.toBean(JSONObject.java:304) at net.sf.json.JSONObject.toBean(JSONObject.java:420) at net.sf.json.JSONSerializer.toJava(JSONSerializer.java:69) ... Like I said, I am able to get the same code to work on other objects, such as Date objects, so what am I missing? Is there a limitation on the types of objects that can be converted to JSONObject and back? Any help or pointers is greatly appreciated! Darlene |
From: Darlene W. <dar...@gm...> - 2008-06-06 22:08:33
|
Hi, I'm new to json-lib. I want to convert a Java class into JSONObject and then back again. I am able to do this conversion with a Date class. However, the class I want to convert contains a nested XMLGregorianCalendar object, which has issues when converting from JSONObject to Java. I've tried to create a simple test case that converts only a GregorianCalendar object ( http://java.sun.com/javase/6/docs/api/java/util/GregorianCalendar.html). This works fine when converting from Java to JSONObject, but the reverse conversion gives an InstantiationException error when calling toJava(). Here is my sample code: GregorianCalendar gc = DateUtil.getCalendar(-7); System.out.println(gc.toString()); // Convert object to JSON JSONObject jsonObject = (JSONObject) JSONSerializer.toJSON(gc); System.out.println(jsonObject.toString()); // Convert JSON object back into Java object GregorianCalendar gc2; JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setRootClass(GregorianCalendar.class); gc2 = (GregorianCalendar) JSONSerializer.toJava(jsonObject, jsonConfig); System.out.println(gc2.toString()); The output is as follows: java.util.GregorianCalendar[time=1212788878236,areFieldsSet=true,areAllFieldsSet=true,lenient=true,zone=java.util.SimpleTimeZone[id=GMT-07:00,offset=-25200000,dstSavings=3600000,useDaylight=true,startYear=0,startMode=3,startMonth=3,startDay=1,startDayOfWeek=1,startTime=7200000,startTimeMode=0,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=7200000,endTimeMode=0],firstDayOfWeek=1,minimalDaysInFirstWeek=1,ERA=1,YEAR=2008,MONTH=5,WEEK_OF_YEAR=23,WEEK_OF_MONTH=1,DAY_OF_MONTH=6,DAY_OF_YEAR=158,DAY_OF_WEEK=6,DAY_OF_WEEK_IN_MONTH=1,AM_PM=1,HOUR=3,HOUR_OF_DAY=15,MINUTE=47,SECOND=58,MILLISECOND=236,ZONE_OFFSET=-25200000,DST_OFFSET=3600000] {"firstDayOfWeek":1,"gregorianChange":{"date":4,"day":4,"hours":16,"minutes":0,"month":9,"seconds":0,"time":-12219292800000,"timezoneOffset":480,"year":-318},"lenient":true,"minimalDaysInFirstWeek":1,"time":{"date":6,"day":5,"hours":14,"minutes":47,"month":5,"seconds":58,"time":1212788878236,"timezoneOffset":420,"year":108},"timeInMillis":1212788878236,"timeZone":{"DSTSavings":3600000,"ID":"GMT-07:00","displayName":"GMT-07:00","rawOffset":-25200000}} net.sf.json.JSONException: java.lang.InstantiationException at net.sf.json.JSONObject.toBean(JSONObject.java:304) at net.sf.json.JSONObject.toBean(JSONObject.java:420) at net.sf.json.JSONSerializer.toJava(JSONSerializer.java:69) ... Like I said, I am able to get the same code to work on other objects, such as Date objects, so what am I missing? Is there a limitation on the types of objects that can be converted to JSONObject and back? Any help or pointers is greatly appreciated! Darlene |
From: Kevin S. <kev...@gm...> - 2008-06-05 21:14:17
|
Please disregard this question. Of course after I sent this email I tried 'println myJson.toString()' instead of just 'println myJson'. When doing 'println myJson.toString()' the json output is indeed correct. Thanks, Kevin On Thu, Jun 5, 2008 at 4:00 PM, Kevin Shekleton <kev...@gm...> wrote: > Using: > * json-lib-2.2.1-jdk15.jar > * groovy-all-minimal-1.5.6.jar > > The current JsonGroovyBuilder javadoc [1] gives 6 examples for constructing > a Books object. Quoting from the javadoc: > > *all 6 books variables output the same JSON > > {"books": { > "book": [{ > "title": "The Definitive Guide to Grails", > "author": "Graeme Rocher" > },{ > "title": "The Definitive Guide to Grails", > "author": "Graeme Rocher" > }] > } > }* > > However, when I try all 6 examples from the javadoc, the json produced is > different. Namely, rather than being objects {}, the output is arrays []. > > *["books": [ > "book": [[ > "title":"The Definitive Guide to Grails", > "author":"Graeme Rocher" > ],[ > "title":"The Definitive Guide to Grails", > "author":"Graeme Rocher" > ]] > ] > ]* > > Is this expected behavior? > > Thanks, > Kevin > > [1] > http://json-lib.sourceforge.net/apidocs/jdk15/net/sf/json/groovy/JsonGroovyBuilder.html > |
From: Kevin S. <kev...@gm...> - 2008-06-05 21:00:08
|
Using: * json-lib-2.2.1-jdk15.jar * groovy-all-minimal-1.5.6.jar The current JsonGroovyBuilder javadoc [1] gives 6 examples for constructing a Books object. Quoting from the javadoc: *all 6 books variables output the same JSON {"books": { "book": [{ "title": "The Definitive Guide to Grails", "author": "Graeme Rocher" },{ "title": "The Definitive Guide to Grails", "author": "Graeme Rocher" }] } }* However, when I try all 6 examples from the javadoc, the json produced is different. Namely, rather than being objects {}, the output is arrays []. *["books": [ "book": [[ "title":"The Definitive Guide to Grails", "author":"Graeme Rocher" ],[ "title":"The Definitive Guide to Grails", "author":"Graeme Rocher" ]] ] ]* Is this expected behavior? Thanks, Kevin [1] http://json-lib.sourceforge.net/apidocs/jdk15/net/sf/json/groovy/JsonGroovyBuilder.html |
From: Andres A. <aal...@ya...> - 2008-05-24 01:28:04
|
If that is the case then your JSONObjects must contain a 'class' key, the only way for you to filter it out is by registering a PropertyFilter with jsonConfig.setJavaPropertyFilter() 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: Kiril <kir...@gm...> To: Andres Almiray <aal...@ya...> Cc: jso...@li... Sent: Friday, May 23, 2008 2:52:34 PM Subject: Re: [json-lib-user] Error message when transforming to Bean No, not at all, all I do with jsonConfig is to set the Root class: jsonConfig.setRootClass( Filter.class ); The problem occurs when morphing beans from json, not reading them. In this case the missing method is a setter for the class property... Kiril. On Fri, May 23, 2008 at 4:34 PM, Andres Almiray <aal...@ya...> wrote: Hi Kiril, Are you by any chance overriding the default exclusion flags by setting jsonConfig.setIgnoreDefaultExcludes(true) ? JsonConfig will exclude class, metaClass and declaringClass properties by default, any property that does not have a read method and has not been excluded nor filtered out would trigger a logging warning (as it seems to be your case). 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: Kiril <kir...@gm...> To: jso...@li... Sent: Friday, May 23, 2008 1:00:36 PM Subject: [json-lib-user] Error message when transforming to Bean Hi all, I use BeanMorpher to get classes from JSON, all works Ok, but each time I get this message: Property 'MyClass.class' has no write method. SKIPPED. As I use this frequently, the log is full with these. Any idea what I must do to avoid this? I understand that some setter is expected, but which one?? Here is the code: Morpher myMorpher = new BeanMorpher( MyClass.class,morpherRegistry); morpherRegistry.registerMorpher(myMorpher); MyClass.class = (MyClass)morpherRegistry.morph(MyClass.class,json); Thanks in advance, Kiril. |
From: Kiril <kir...@gm...> - 2008-05-23 21:52:38
|
No, not at all, all I do with jsonConfig is to set the Root class: jsonConfig.setRootClass( Filter.class ); The problem occurs when morphing beans from json, not reading them. In this case the missing method is a setter for the class property... Kiril. On Fri, May 23, 2008 at 4:34 PM, Andres Almiray <aal...@ya...> wrote: > Hi Kiril, > > Are you by any chance overriding the default exclusion flags by setting > jsonConfig.setIgnoreDefaultExcludes(true) ? > JsonConfig will exclude class, metaClass and declaringClass properties by > default, any property that does not have a read method and has not been > excluded nor filtered out would trigger a logging warning (as it seems to be > your case). > > 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: Kiril <kir...@gm...> > To: jso...@li... > Sent: Friday, May 23, 2008 1:00:36 PM > Subject: [json-lib-user] Error message when transforming to Bean > > Hi all, > > I use BeanMorpher to get classes from JSON, all works Ok, but each time I > get this message: > Property 'MyClass.class' has no write method. SKIPPED. > As I use this frequently, the log is full with these. > Any idea what I must do to avoid this? I understand that some setter is > expected, but which one?? > > Here is the code: > Morpher myMorpher = new BeanMorpher( MyClass.class,morpherRegistry); > morpherRegistry.registerMorpher(myMorpher); > MyClass.class = (MyClass)morpherRegistry.morph(MyClass.class,json); > > Thanks in advance, > > Kiril. > > |
From: Andres A. <aal...@ya...> - 2008-05-23 20:34:43
|
Hi Kiril, Are you by any chance overriding the default exclusion flags by setting jsonConfig.setIgnoreDefaultExcludes(true) ? JsonConfig will exclude class, metaClass and declaringClass properties by default, any property that does not have a read method and has not been excluded nor filtered out would trigger a logging warning (as it seems to be your case). 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: Kiril <kir...@gm...> To: jso...@li... Sent: Friday, May 23, 2008 1:00:36 PM Subject: [json-lib-user] Error message when transforming to Bean Hi all, I use BeanMorpher to get classes from JSON, all works Ok, but each time I get this message: Property 'MyClass.class' has no write method. SKIPPED. As I use this frequently, the log is full with these. Any idea what I must do to avoid this? I understand that some setter is expected, but which one?? Here is the code: Morpher myMorpher = new BeanMorpher( MyClass.class,morpherRegistry); morpherRegistry.registerMorpher(myMorpher); MyClass.class = (MyClass)morpherRegistry.morph(MyClass.class,json); Thanks in advance, Kiril. |