json-lib-user Mailing List for Json-lib (Page 6)
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: Kiril <kir...@gm...> - 2008-05-23 20:00:38
|
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-13 06:59:13
|
Hi Andres, Thank you for the reply. I tested this, and it works! I noticed that by creating the object as below, you can omit the need for the Map: JSONObject jsonObject = new JSONObject(); JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setRootClass( MyBean.class ); jsonObject = (JSONObject)JSONSerializer.toJSON(jsonString); MyBean myBean = (MyBean)JSONSerializer.toJava(jsonObject, jsonConfig); Also, the example misses one line: MorpherRegistry morpherRegistry = JSONUtils.getMorpherRegistry(); Again, thanks a lot! On Sat, May 10, 2008 at 11:42 AM, Andres Almiray <aal...@ya...> wrote: > Hi Kiril, > > That code would surely work but ties your domain to Json-lib, the docs ( > http://json-lib.sourceforge.net/usage.html) include an alternative > solution to your problem: registering a BeanMorpher. > > > 1. class MyBean{ > 2. private List data; > 3. // getters & setters > 4. } > 5. > 6. class Person{ > 7. private String name; > 8. // getters & setters > 9. } > 10. > 11. ... > 12. > 13. String json = "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}" > ; > 14. Map classMap = new HashMap(); > 15. classMap.put( "data", Person.class ); > 16. > MyBean bean = JSONObject.toBean( JSONObject.fromObject(json), MyBean. > class, classMap ); > > > 1. Morpher dynaMorpher = new BeanMorpher( Person.class > , JSONUtils.getMorpherRegistry() ); > 2. morpherRegistry.registerMorpher( dynaMorpher ); > 3. List output = new ArrayList(); > 4. for( Iterator i = bean.getData().iterator(); i.hasNext(); ){ > 5. output.add( morpherRegistry.morph( Person.class > , i.next() ) ); > 6. } > 7. bean.setData( output ); > > 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: Saturday, May 10, 2008 12:54:57 AM > Subject: Re: [json-lib-user] Problems with .toJava > > Ok, > > I'm not a newbie anymore :) > > Here is the solution, if anyone is interested. I modified the setter in > the root class for the list of children (Group classes): > > public void setGroups(List<Group> groups) { > for(int i=0; i < groups.size(); i++) { > Group grp = null; > BeanMorpher mrph = new BeanMorpher(Group.class, > JSONUtils.getMorpherRegistry()); > grp = (Group)mrph.morph(groups.get(i)); > this.groups.add(grp); > } > } > > Yahoo!!!... Works! > > > On Sat, May 10, 2008 at 2:55 AM, Kiril <kir...@gm...> wrote: > > > May be attaching the json string will help: > > > > > > {"groups":[{"comparison":"And","fields":[{"comparison":"Near","field":"subject","values":["Daily","Report"]},{"comparison":"Equals","field":"message","values":["November"]}],"nextGroupComparison":"Or"},{"comparison":"Null","fields":[{"comparison":"Equals","field":"message","values":["October"]}],"nextGroupComparison":"Null"}],"revision":0,"version":1} > > > > > > On Sat, May 10, 2008 at 2:54 AM, Kiril <kir...@gm...> wrote: > > > > > Hi all, > > > > > > I'm newbie to json-lib. > > > I want to use it to serialize a class with a List<Class>, containing > > > number of subclasses. > > > > > > While toJSON works fine, passing back the same string to toJava works > > > only partially - the root class is generated Ok, but the children, in the > > > List are MorphDynaBean's. > > > > > > Here is the code: > > > > > > JSONUtils.getMorpherRegistry().registerMorpher(new > > > EnumMorpher(GroupComparison.class)); > > > JSONUtils.getMorpherRegistry().registerMorpher(new > > > EnumMorpher(NextGroupComparison.class)); > > > JSONUtils.getMorpherRegistry().registerMorpher(new > > > EnumMorpher(FieldComparison.class)); > > > JSONObject jsonObject = new JSONObject(); > > > JsonConfig jsonConfig = new JsonConfig(); > > > jsonConfig.setRootClass( Filter.class ); > > > jsonConfig.setEnclosedType(List.class); > > > jsonObject = > > > (JSONObject)JSONSerializer.toJSON(jsonString); > > > Filter filter = (Filter)JSONSerializer.toJava(jsonObject, > > > jsonConfig); > > > > > > The Filter class contains List of Group classes, but these are > > > generated as a MorphDynaBean... > > > > > > Thanks in advance for any help! > > > > > > Kiril. > > > > > > > > > ------------------------------ > 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-05-10 15:42:48
|
Hi Kiril, That code would surely work but ties your domain to Json-lib, the docs (http://json-lib.sourceforge.net/usage.html) include an alternative solution to your problem: registering a BeanMorpher. 1. class MyBean{ 2. private List data; 3. // getters & setters 4. } 5. 6. class Person{ 7. private String name; 8. // getters & setters 9. } 10. 11. ... 12. 13. String json = "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}"; 14. Map classMap = new HashMap(); 15. classMap.put( "data", Person.class ); 16. MyBean bean = JSONObject.toBean( JSONObject.fromObject(json), MyBean.class, classMap ); 1. Morpher dynaMorpher = new BeanMorpher( Person.class, JSONUtils.getMorpherRegistry() ); 2. morpherRegistry.registerMorpher( dynaMorpher ); 3. List output = new ArrayList(); 4. for( Iterator i = bean.getData().iterator(); i.hasNext(); ){ 5. output.add( morpherRegistry.morph( Person.class, i.next() ) ); 6. } 7. bean.setData( output ); 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: Saturday, May 10, 2008 12:54:57 AM Subject: Re: [json-lib-user] Problems with .toJava Ok, I'm not a newbie anymore :) Here is the solution, if anyone is interested. I modified the setter in the root class for the list of children (Group classes): public void setGroups(List<Group> groups) { for(int i=0; i < groups.size(); i++) { Group grp = null; BeanMorpher mrph = new BeanMorpher(Group.class, JSONUtils.getMorpherRegistry()); grp = (Group)mrph.morph(groups.get(i)); this.groups.add(grp); } } Yahoo!!!... Works! On Sat, May 10, 2008 at 2:55 AM, Kiril <kir...@gm...> wrote: May be attaching the json string will help: {"groups":[{"comparison":"And","fields":[{"comparison":"Near","field":"subject","values":["Daily","Report"]},{"comparison":"Equals","field":"message","values":["November"]}],"nextGroupComparison":"Or"},{"comparison":"Null","fields":[{"comparison":"Equals","field":"message","values":["October"]}],"nextGroupComparison":"Null"}],"revision":0,"version":1} On Sat, May 10, 2008 at 2:54 AM, Kiril <kir...@gm...> wrote: Hi all, I'm newbie to json-lib. I want to use it to serialize a class with a List<Class>, containing number of subclasses. While toJSON works fine, passing back the same string to toJava works only partially - the root class is generated Ok, but the children, in the List are MorphDynaBean's. Here is the code: JSONUtils.getMorpherRegistry().registerMorpher(new EnumMorpher(GroupComparison.class)); JSONUtils.getMorpherRegistry().registerMorpher(new EnumMorpher(NextGroupComparison.class)); JSONUtils.getMorpherRegistry().registerMorpher(new EnumMorpher(FieldComparison.class)); JSONObject jsonObject = new JSONObject(); JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setRootClass( Filter.class ); jsonConfig.setEnclosedType(List.class); jsonObject = (JSONObject)JSONSerializer.toJSON(jsonString); Filter filter = (Filter)JSONSerializer.toJava(jsonObject, jsonConfig); The Filter class contains List of Group classes, but these are generated as a MorphDynaBean... Thanks in advance for any help! Kiril. ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |
From: Kiril <kir...@gm...> - 2008-05-10 07:54:58
|
Ok, I'm not a newbie anymore :) Here is the solution, if anyone is interested. I modified the setter in the root class for the list of children (Group classes): public void setGroups(List<Group> groups) { for(int i=0; i < groups.size(); i++) { Group grp = null; BeanMorpher mrph = new BeanMorpher(Group.class, JSONUtils.getMorpherRegistry()); grp = (Group)mrph.morph(groups.get(i)); this.groups.add(grp); } } Yahoo!!!... Works! On Sat, May 10, 2008 at 2:55 AM, Kiril <kir...@gm...> wrote: > May be attaching the json string will help: > > > {"groups":[{"comparison":"And","fields":[{"comparison":"Near","field":"subject","values":["Daily","Report"]},{"comparison":"Equals","field":"message","values":["November"]}],"nextGroupComparison":"Or"},{"comparison":"Null","fields":[{"comparison":"Equals","field":"message","values":["October"]}],"nextGroupComparison":"Null"}],"revision":0,"version":1} > > > On Sat, May 10, 2008 at 2:54 AM, Kiril <kir...@gm...> wrote: > >> Hi all, >> >> I'm newbie to json-lib. >> I want to use it to serialize a class with a List<Class>, containing >> number of subclasses. >> >> While toJSON works fine, passing back the same string to toJava works only >> partially - the root class is generated Ok, but the children, in the List >> are MorphDynaBean's. >> >> Here is the code: >> >> JSONUtils.getMorpherRegistry().registerMorpher(new >> EnumMorpher(GroupComparison.class)); >> JSONUtils.getMorpherRegistry().registerMorpher(new >> EnumMorpher(NextGroupComparison.class)); >> JSONUtils.getMorpherRegistry().registerMorpher(new >> EnumMorpher(FieldComparison.class)); >> JSONObject jsonObject = new JSONObject(); >> JsonConfig jsonConfig = new JsonConfig(); >> jsonConfig.setRootClass( Filter.class ); >> jsonConfig.setEnclosedType(List.class); >> jsonObject = (JSONObject)JSONSerializer.toJSON(jsonString); >> Filter filter = (Filter)JSONSerializer.toJava(jsonObject, >> jsonConfig); >> >> The Filter class contains List of Group classes, but these are generated >> as a MorphDynaBean... >> >> Thanks in advance for any help! >> >> Kiril. >> > > |
From: Kiril <kir...@gm...> - 2008-05-10 06:56:15
|
May be attaching the json string will help: {"groups":[{"comparison":"And","fields":[{"comparison":"Near","field":"subject","values":["Daily","Report"]},{"comparison":"Equals","field":"message","values":["November"]}],"nextGroupComparison":"Or"},{"comparison":"Null","fields":[{"comparison":"Equals","field":"message","values":["October"]}],"nextGroupComparison":"Null"}],"revision":0,"version":1} On Sat, May 10, 2008 at 2:54 AM, Kiril <kir...@gm...> wrote: > Hi all, > > I'm newbie to json-lib. > I want to use it to serialize a class with a List<Class>, containing number > of subclasses. > > While toJSON works fine, passing back the same string to toJava works only > partially - the root class is generated Ok, but the children, in the List > are MorphDynaBean's. > > Here is the code: > > JSONUtils.getMorpherRegistry().registerMorpher(new > EnumMorpher(GroupComparison.class)); > JSONUtils.getMorpherRegistry().registerMorpher(new > EnumMorpher(NextGroupComparison.class)); > JSONUtils.getMorpherRegistry().registerMorpher(new > EnumMorpher(FieldComparison.class)); > JSONObject jsonObject = new JSONObject(); > JsonConfig jsonConfig = new JsonConfig(); > jsonConfig.setRootClass( Filter.class ); > jsonConfig.setEnclosedType(List.class); > jsonObject = (JSONObject)JSONSerializer.toJSON(jsonString); > Filter filter = (Filter)JSONSerializer.toJava(jsonObject, > jsonConfig); > > The Filter class contains List of Group classes, but these are generated as > a MorphDynaBean... > > Thanks in advance for any help! > > Kiril. > |
From: Kiril <kir...@gm...> - 2008-05-10 06:54:37
|
Hi all, I'm newbie to json-lib. I want to use it to serialize a class with a List<Class>, containing number of subclasses. While toJSON works fine, passing back the same string to toJava works only partially - the root class is generated Ok, but the children, in the List are MorphDynaBean's. Here is the code: JSONUtils.getMorpherRegistry().registerMorpher(new EnumMorpher(GroupComparison.class)); JSONUtils.getMorpherRegistry().registerMorpher(new EnumMorpher(NextGroupComparison.class)); JSONUtils.getMorpherRegistry().registerMorpher(new EnumMorpher(FieldComparison.class)); JSONObject jsonObject = new JSONObject(); JsonConfig jsonConfig = new JsonConfig(); jsonConfig.setRootClass( Filter.class ); jsonConfig.setEnclosedType(List.class); jsonObject = (JSONObject)JSONSerializer.toJSON(jsonString); Filter filter = (Filter)JSONSerializer.toJava(jsonObject, jsonConfig); The Filter class contains List of Group classes, but these are generated as a MorphDynaBean... Thanks in advance for any help! Kiril. |
From: Costa B. <cos...@ya...> - 2008-03-27 22:02:44
|
This is what I suspected. Because there is no JSON*** object to emulate an object constructor call. For now I will just simply extend the json.org api (which was incorporated to this lib) to generate the constructor call. ----- Original Message ---- From: Andres Almiray <aal...@ya...> To: Costa Basil <cos...@ya...>; jso...@li... Sent: Thursday, March 27, 2008 2:21:09 PM Subject: Re: [json-lib-user] serializing to new <Object>(<parameters>) Yes, you can but it may not turn out to be exactly as you would expect. You can register a JsonBeanProcessor or a JsonValueProcessor that takes care of marshalling the property, you'll need to return a valid JSON value [JSON,null,Number,String,Boolean,JSONFunction] so in your case you'll return a String, something like "new Date( <params> )", which means that when the json string is deserialized on the browser the date won't be automatically created. Enabling arbitrary JS code as property value is a big no-no in many circles but I can clearly see the advantages of doing so, specially if you have the proper security measures in place. Perhaps this can be added as a feature. 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: Costa Basil <cos...@ya...> To: jso...@li... Sent: Thursday, March 27, 2008 1:30:17 PM Subject: [json-lib-user] serializing to new <Object>(<parameters>) Is it possible, using json-lib, to serialize an object to a javascript new operator call. For instance, to serialize to a Date value, I would serialize it to new Date(<here go the constructor parameters>). Thanks Ask a question on any topic and get answers from real people. Go to Yahoo! Answers. Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. __________________________________________________________________ Yahoo! Canada Toolbar: Search from anywhere on the web, and bookmark your favourite sites. Download it now at http://ca.toolbar.yahoo.com. |
From: Andres A. <aal...@ya...> - 2008-03-27 21:21:16
|
Yes, you can but it may not turn out to be exactly as you would expect. You can register a JsonBeanProcessor or a JsonValueProcessor that takes care of marshalling the property, you'll need to return a valid JSON value [JSON,null,Number,String,Boolean,JSONFunction] so in your case you'll return a String, something like "new Date( <params> )", which means that when the json string is deserialized on the browser the date won't be automatically created. Enabling arbitrary JS code as property value is a big no-no in many circles but I can clearly see the advantages of doing so, specially if you have the proper security measures in place. Perhaps this can be added as a feature. 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: Costa Basil <cos...@ya...> To: jso...@li... Sent: Thursday, March 27, 2008 1:30:17 PM Subject: [json-lib-user] serializing to new <Object>(<parameters>) Is it possible, using json-lib, to serialize an object to a javascript new operator call. For instance, to serialize to a Date value, I would serialize it to new Date(<here go the constructor parameters>). Thanks Ask a question on any topic and get answers from real people. Go to Yahoo! Answers. ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping |
From: Costa B. <cos...@ya...> - 2008-03-27 20:30:50
|
Is it possible, using json-lib, to serialize an object to a javascript new operator call. For instance, to serialize to a Date value, I would serialize it to new Date(<here go the constructor parameters>). Thanks __________________________________________________________________ Connect with friends from any web browser - no download required. Try the new Yahoo! Canada Messenger for the Web BETA at http://ca.messenger.yahoo.com/webmessengerpromo.php |
From: Andres A. <aal...@ya...> - 2008-03-24 22:11:40
|
Thanks Philippe, I will review the code, see how it can be added to the current build without breaking the jdk3 package. 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: Philippe Kernevez <pke...@oc...> To: Andres Almiray <aal...@ya...>; jso...@li... Cc: André Nedelcoux <ane...@oc...>; Hub...@ca... Sent: Friday, March 21, 2008 4:41:21 AM Subject: RE: [json-lib-user] Java 5 <!-- _filtered {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;} _filtered {font-family:"Comic Sans MS";panose-1:3 15 7 2 3 3 2 2 2 4;} _filtered {margin:72.0pt 90.0pt 72.0pt 90.0pt;} _filtered {} _filtered {} _filtered {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue;text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {color:purple;text-decoration:underline;} p {margin-right:0cm;margin-left:0cm;font-size:12.0pt;font-family:"Times New Roman";} span.emailstyle17 {font-family:Arial;color:windowtext;} span.EmailStyle19 {font-family:Arial;color:navy;} _filtered {margin:72.0pt 90.0pt 72.0pt 90.0pt;} div.Section1 {} --> Hi, This is our JSON5Utils class. There is a lot of test with it, I expect that they will be enough for understand it. If you need help, ask for me. We are using this code for 2 weeks without any trouble. Regards, Philippe From: Andres Almiray[mailto:aal...@ya...] Sent: jeudi 6 mars 2008 20:56 To: Philippe Kernevez;jso...@li... Subject: Re: [json-lib-user] Java5 Hi Phllippe, As a matter of fact, generics support is one of the target features for ournext release, 2.3, so we would be very glad to review your patch and somehow accommodate the1.3/1.5 build we currently have. I'm not aware of a CVS->SVN url conversion, when I started the project I hadonly the choice for CVS repositories =-( Regards, 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, andthose who don't. To understand recursion, we must first understand recursion. ----- Original Message---- From: Philippe Kernevez <pke...@oc...> To: jso...@li... Sent: Thursday, March 6, 2008 8:42:31 AM Subject: [json-lib-user] Java 5 Hi, I am new to JSON-lib, may be my question is a newbie answer. I saw that there is a jdk15 version and Im using it. It seems that this version isnt really full jdk 5, is there some plan to have more java 5 compliant API? What do it mean? 1) A Generics API public class JSONObject { public static <T> T toBean( JSONObject jsonObject, Class<T> beanClass, Map classMap ) { } } 2) An automatic collection mapping based on Generics With such functionality, you example with EZMorph: http://json-lib.sourceforge.net/usage.html#From%20JSON%20to%20Beansin the From JSON to Beans will become: String json = "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}"; MyBean bean = JSON5Utils.toBean( JSONObject.fromObject(json), MyBean.class, classMap ); Instead of String json = "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}"; Map classMap = new HashMap(); classMap.put( "data", Person.class ); MyBean bean = (MyBean)JSONObject.toBean( JSONObject.fromObject(json), MyBean.class, classMap ); I already have code and tests for that functionalities, are you interesting by It and how do you want it (I cant give you a patch on you actual project, it only compiles with Java5) ? An independent Maven project? Another and independent question: is there an Svn connection URL instead of the cvs (I found the CVS one, but I cant succeed in converting it to standard sourceforge Svn url) ? Regards, Philippe Cemessage Envoi est certifié sans virus connu (AVG Pro). Analyse effectuée par AVG. Version: 7.5.516 / Base de données virus: 269.21.5/1314 - Date: 05/03/200818:38 -----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 Looking for last minute shopping deals? Find them fast with Yahoo! Search. Ce message Envoi est certifié sans virus connu (AVG Pro). Analyse effectuée par AVG. Version: 7.5.519 / Base de données virus: 269.21.8/1337 - Date: 20/03/2008 20:10 ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs |
From: Andres A. <aal...@ya...> - 2008-03-06 22:06:35
|
Hi Phillipe, Answers to your questions: 1) 2.3-SNAPSHOT is the current dev trunk as you guessed 2) both maven and ant are used, maven is useful for creating the site docs and some artifacts, but all distro jars are created using the ant build. 3) I think a standalone maven project will be ok, as I believe we must either retrofit JSONUtils with the new code or overwrite it with your version, same way as it is done with JSONObject/JSONArray to handle jdk13/jdk15 (which is the main reason for building with ant). Cheers, Andres ----- Original Message ---- From: Philippe Kernevez <pke...@oc...> To: jso...@li... Sent: Thursday, March 6, 2008 1:26:00 PM Subject: Re: [json-lib-user] Java 5 <!-- _filtered {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;} _filtered {font-family:"Comic Sans MS";panose-1:3 15 7 2 3 3 2 2 2 4;} _filtered {margin:72.0pt 90.0pt 72.0pt 90.0pt;} _filtered {} _filtered {} _filtered {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue;text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {color:purple;text-decoration:underline;} p {margin-right:0cm;margin-left:0cm;font-size:12.0pt;font-family:"Times New Roman";} span.emailstyle17 {font-family:Arial;color:windowtext;} span.EmailStyle19 {font-family:Arial;color:navy;} _filtered {margin:72.0pt 90.0pt 72.0pt 90.0pt;} div.Section1 {} --> Hi Andres, Where can I find the 2.3-SNAPSHOT (our your dev trunk) for creating the patch ? If it isn't published, I can send it as another small Maven project. Or do you prefer a patch in the main/jdk15 folder ? Which build do you use ? The Maven or the ANT one ? (I don't understand how to build the both version with Maven, may be you pass some command line argument?). Regards, Philippe From: Andres Almiray[mailto:aal...@ya...] Sent: jeudi 6 mars 2008 20:56 To: Philippe Kernevez;jso...@li... Subject: Re: [json-lib-user] Java5 Hi Phllippe, As a matter of fact, generics support is one of the target features for ournext release, 2.3, so we would be very glad to review your patch and somehow accommodate the1.3/1.5 build we currently have. I'm not aware of a CVS->SVN url conversion, when I started the project I hadonly the choice for CVS repositories =-( Regards, 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, andthose who don't. To understand recursion, we must first understand recursion. ----- Original Message---- From: Philippe Kernevez <pke...@oc...> To: jso...@li... Sent: Thursday, March 6, 2008 8:42:31 AM Subject: [json-lib-user] Java 5 Hi, I am new to JSON-lib, may be my question is a newbie answer. I saw that there is a jdk15 version and I’m using it. It seems that this version isn’t really full jdk 5, is there some plan to have more java 5 compliant API? What do it mean? 1) A Generics API public class JSONObject { … public static <T> T toBean( JSONObject jsonObject, Class<T> beanClass, Map classMap ) {…} } 2) An automatic collection mapping based on Generics With such functionality, you example with EZMorph: http://json-lib.sourceforge.net/usage.html#From%20JSON%20to%20Beansin the “From JSON to Beans” will become: String json = "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}"; MyBean bean = JSON5Utils.toBean( JSONObject.fromObject(json), MyBean.class, classMap ); Instead of String json = "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}"; Map classMap = new HashMap(); classMap.put( "data", Person.class ); MyBean bean = (MyBean)JSONObject.toBean( JSONObject.fromObject(json), MyBean.class, classMap ); I already have code and tests for that functionalities, are you interesting by It and how do you want it (I can’t give you a patch on you actual project, it only compiles with Java5) ? An independent Maven project? Another and independent question: is there an Svn connection URL instead of the cvs (I found the CVS one, but I can’t succeed in converting it to standard sourceforge Svn url) ? Regards, Philippe Cemessage Envoi est certifié sans virus connu (AVG Pro). Analyse effectuée par AVG. Version: 7.5.516 / Base de données virus: 269.21.5/1314 - Date: 05/03/200818:38 -----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 Looking for last minute shopping deals? Find them fast with Yahoo! Search. Ce message Envoi est certifié sans virus connu (AVG Pro). Analyse effectuée par AVG. Version: 7.5.516 / Base de données virus: 269.21.5/1314 - Date: 05/03/2008 18:38 -----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: Philippe K. <pke...@oc...> - 2008-03-06 21:26:39
|
Hi Andres, Where can I find the 2.3-SNAPSHOT (our your dev trunk) for creating the patch ? If it isn't published, I can send it as another small Maven project. Or do you prefer a patch in the main/jdk15 folder ? Which build do you use ? The Maven or the ANT one ? (I don't understand how to build the both version with Maven, may be you pass some command line argument?). Regards, Philippe _____ From: Andres Almiray [mailto:aal...@ya...] Sent: jeudi 6 mars 2008 20:56 To: Philippe Kernevez; jso...@li... Subject: Re: [json-lib-user] Java 5 Hi Phllippe, As a matter of fact, generics support is one of the target features for our next release, 2.3, so we would be very glad to review your patch and somehow accommodate the 1.3/1.5 build we currently have. I'm not aware of a CVS->SVN url conversion, when I started the project I had only the choice for CVS repositories =-( Regards, Andres ------------------------------------------- HYPERLINK "http://jroller.com/aalmiray" \nhttp://jroller.com/aalmiray HYPERLINK "http://www.linkedin.com/in/aalmiray" \nhttp://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: Philippe Kernevez <pke...@oc...> To: jso...@li... Sent: Thursday, March 6, 2008 8:42:31 AM Subject: [json-lib-user] Java 5 Hi, I am new to JSON-lib, may be my question is a newbie answer. I saw that there is a jdk15 version and Im using it. It seems that this version isnt really full jdk 5, is there some plan to have more java 5 compliant API? What do it mean? 1) A Generics API public class JSONObject { public static <T> T toBean( JSONObject jsonObject, Class<T> beanClass, Map classMap ) { } } 2) An automatic collection mapping based on Generics With such functionality, you example with EZMorph: HYPERLINK "http://json-lib.sourceforge.net/usage.html#From%20JSON%20to%20Beans" \nhttp://json-lib.sourceforge.net/usage.html#From%20JSON%20to%20Beans in the From JSON to Beans will become: String json = "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}"; MyBean bean = JSON5Utils.toBean( JSONObject.fromObject(json), MyBean.class, classMap ); Instead of String json = "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}"; Map classMap = new HashMap(); classMap.put( "data", Person.class ); MyBean bean = (MyBean)JSONObject.toBean( JSONObject.fromObject(json), MyBean.class, classMap ); I already have code and tests for that functionalities, are you interesting by It and how do you want it (I cant give you a patch on you actual project, it only compiles with Java5) ? An independent Maven project? Another and independent question: is there an Svn connection URL instead of the cvs (I found the CVS one, but I cant succeed in converting it to standard sourceforge Svn url) ? Regards, Philippe Ce message Envoi est certifié sans virus connu (AVG Pro). Analyse effectuée par AVG. Version: 7.5.516 / Base de données virus: 269.21.5/1314 - Date: 05/03/2008 18:38 -----Inline Attachment Follows----- ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. HYPERLINK "http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/" \nhttp://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ -----Inline Attachment Follows----- _______________________________________________ json-lib-user mailing list HYPERLINK "mailto:jso...@li..."jso...@li...urceforge. net HYPERLINK "https://lists.sourceforge.net/lists/listinfo/json-lib-user" \nhttps://lists.sourceforge.net/lists/listinfo/json-lib-user _____ Looking for last minute shopping deals? HYPERLINK "http://us.rd.yahoo.com/evt=51734/*http:/tools.search.yahoo.com/newsearch/ca tegory.php?category=shopping"Find them fast with Yahoo! Search. Ce message Envoi est certifié sans virus connu (AVG Pro). Analyse effectuée par AVG. Version: 7.5.516 / Base de données virus: 269.21.5/1314 - Date: 05/03/2008 18:38 |
From: Andres A. <aal...@ya...> - 2008-03-06 19:56:01
|
Hi Phllippe, As a matter of fact, generics support is one of the target features for our next release, 2.3, so we would be very glad to review your patch and somehow accommodate the 1.3/1.5 build we currently have. I'm not aware of a CVS->SVN url conversion, when I started the project I had only the choice for CVS repositories =-( Regards, 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: Philippe Kernevez <pke...@oc...> To: jso...@li... Sent: Thursday, March 6, 2008 8:42:31 AM Subject: [json-lib-user] Java 5 <!-- _filtered {font-family:Tahoma;panose-1:2 11 6 4 3 5 4 4 2 4;} _filtered {font-family:"Comic Sans MS";panose-1:3 15 7 2 3 3 2 2 2 4;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm;margin-bottom:.0001pt;font-size:12.0pt;font-family:"Times New Roman";} a:link, span.MsoHyperlink {color:blue;text-decoration:underline;} a:visited, span.MsoHyperlinkFollowed {color:purple;text-decoration:underline;} span.EmailStyle17 {font-family:Arial;color:windowtext;} _filtered {margin:72.0pt 90.0pt 72.0pt 90.0pt;} div.Section1 {} _filtered {} _filtered {} ol {margin-bottom:0cm;} ul {margin-bottom:0cm;} --> Hi, I am new to JSON-lib, may be my question is a newbie answer. I saw that there is a jdk15 version and I’m using it. It seems that this version isn’t really full jdk 5, is there some plan to have more java 5 compliant API? What do it mean? 1) A Generics API public class JSONObject { … public static <T> T toBean( JSONObject jsonObject, Class<T> beanClass, Map classMap ) {…} } 2) An automatic collection mapping based on Generics With such functionality, you example with EZMorph: http://json-lib.sourceforge.net/usage.html#From%20JSON%20to%20Beansin the “From JSON to Beans” will become: String json = "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}"; MyBean bean = JSON5Utils.toBean( JSONObject.fromObject(json), MyBean.class, classMap ); Instead of String json = "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}"; Map classMap = new HashMap(); classMap.put( "data", Person.class ); MyBean bean = (MyBean)JSONObject.toBean( JSONObject.fromObject(json), MyBean.class, classMap ); I already have code and tests for that functionalities, are you interesting by It and how do you want it (I can’t give you a patch on you actual project, it only compiles with Java5) ? An independent Maven project? Another and independent question: is there an Svn connection URL instead of the cvs (I found the CVS one, but I can’t succeed in converting it to standard sourceforge Svn url) ? Regards, Philippe Ce message Envoi est certifié sans virus connu (AVG Pro). Analyse effectuée par AVG. Version: 7.5.516 / Base de données virus: 269.21.5/1314 - Date: 05/03/2008 18:38 -----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 ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping |
From: Philippe K. <pke...@oc...> - 2008-03-06 16:44:10
|
Hi, I am new to JSON-lib, may be my question is a newbie answer. I saw that there is a jdk15 version and I’m using it. It seems that this version isn’t really full jdk 5, is there some plan to have more java 5 compliant API? What do it mean? 1) A Generics API public class JSONObject { … public static <T> T toBean( JSONObject jsonObject, Class<T> beanClass, Map classMap ) {…} } 2) An automatic collection mapping based on Generics With such functionality, you example with EZMorph: HYPERLINK "http://json-lib.sourceforge.net/usage.html#From%20JSON%20to%20Beans"http:// json-lib.sourceforge.net/usage.html#From%20JSON%20to%20Beans in the “From JSON to Beans” will become: String json = "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}"; MyBean bean = JSON5Utils.toBean( JSONObject.fromObject(json), MyBean.class, classMap ); Instead of String json = "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}"; Map classMap = new HashMap(); classMap.put( "data", Person.class ); MyBean bean = (MyBean)JSONObject.toBean( JSONObject.fromObject(json), MyBean.class, classMap ); I already have code and tests for that functionalities, are you interesting by It and how do you want it (I can’t give you a patch on you actual project, it only compiles with Java5) ? An independent Maven project? Another and independent question: is there an Svn connection URL instead of the cvs (I found the CVS one, but I can’t succeed in converting it to standard sourceforge Svn url) ? Regards, Philippe Ce message Envoi est certifié sans virus connu (AVG Pro). Analyse effectuée par AVG. Version: 7.5.516 / Base de données virus: 269.21.5/1314 - Date: 05/03/2008 18:38 |
From: Sudharshan P. <pol...@gm...> - 2008-02-19 15:09:35
|
---------- Forwarded message ---------- From: Sudharshan Pollapally <pol...@gm...> Date: Feb 14, 2008 4:37 PM Subject: Re: [json-lib-user] XMLSerializer usage for xml text to json conversion To: Andres Almiray <aal...@ya...> Hi Andres, This is what I tried, on jdk 1.4 <pre> import org.json.JSONException; import org.json.XML; import net.sf.json.xml.XMLSerializer; public class JsonTest { public static void main(String[] args) { String xmlStr ="<index><magazine>mag</magazine><issueDate /><promotions /><featureSet><features><sequence>1</sequence><style>set1</style><featuresHeader></featuresHeader><feature><style /></feature></features><features><sequence>2</sequence><style>set2</style><featuresHeader/><feature> <style /></feature><feature> <style /></feature><feature> <style /></feature></features><features><sequence>3</sequence><style>set2</style><featuresHeader/><feature> <style /></feature><feature> <style /></feature><feature> <style /></feature></features><features><sequence>4</sequence><style>set2</style><featuresHeader/><feature> <style /></feature><feature> <style /></feature><feature> <style /></feature></features></featureSet><relatedLinks /></index>"; XMLSerializer xmlSerializer = new XMLSerializer(); xmlSerializer.setForceTopLevelObject(true); xmlSerializer.setTypeHintsCompatibility(false); xmlSerializer.setTypeHintsEnabled(false); xmlSerializer.setSkipWhitespace(true); System.out.println("java.class.path: "+System.getProperty(" java.class.path")); System.out.println("xmlSerializer.read: "+xmlSerializer.read(xmlStr)); try { System.out.println("XML.toJSONObject: "+XML.toJSONObject(xmlStr)); } catch (JSONException e) { } } } </pre> Output: java.class.path: C:\Documents and Settings\workspace\Temp\bin;I:\.maven\repository\ezmorph\jars\ezmorph- 1.0.4.jar;I:\.maven\repository\commons-collections\jars\commons- collections-3.2.jar;I:\.maven\repository\json-lib\jars\json-lib-2.2.1.jar ;I:\.maven\repository\xom\jars\xom-1.1.jar ;I:\.maven\repository\commons-beanutils\jars\commons-beanutils-1.7.jar ;I:\.maven\repository\commons-lang\jars\commons-lang-2.2.jar ;I:\.maven\repository\commons-logging\jars\commons-logging-1.1.jar Feb 14, 2008 4:24:02 PM net.sf.json.xml.XMLSerializer getType INFO: Using default type string xmlSerializer.read: {"magazine":"mag","issueDate":[],"promotions":[],"featureSet":[{"sequence":"1","style":"set1","featuresHeader":[],"feature":[[]]},{"sequence":"2","style":"set2","featuresHeader":[],"feature":[[],[[]],[[]]]},{"sequence":"3","style":"set2","featuresHeader":[],"feature":[[],[[]],[[]]]},{"sequence":"4","style":"set2","featuresHeader":[],"feature":[[],[[]],[[]]]}],"relatedLinks":[]} XML.toJSONObject: {"index":{"featureSet":{"features":[{"style":"set1","featuresHeader":"","feature":{"style":{}},"sequence":"1"},{"style":"set2","featuresHeader":{},"feature":[{"style":{}},{"style":{}},{"style":{}}],"sequence":"2"},{"style":"set2","featuresHeader":{},"feature":[{"style":{}},{"style":{}},{"style":{}}],"sequence":"3"},{"style":"set2","featuresHeader":{},"feature":[{"style":{}},{"style":{}},{"style":{}}],"sequence":"4"}]},"promotions":{},"magazine":"mag","issueDate":{},"relatedLinks":{}}} Notice that <index> and <features> nodes are missing in the string generated by xmlSerializer.read. Thanks, polapali On Thu, Feb 14, 2008 at 3:16 PM, Andres Almiray <aal...@ya...> wrote: > Please send an snippet of your XML (a failing test would be better! =-)) > Your report has little information that can be used to pinpoint the > problem, thanks! > > 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: Sudharshan Pollapally <pol...@gm...> > To: jso...@li... > Sent: Wednesday, February 13, 2008 2:31:43 PM > Subject: [json-lib-user] XMLSerializer usage for xml text to json > conversion > > Hi, > I am trying to use json-lib 2.2.1 XMLSerializer.read(xmlString) to > convert xml text to json, similar to org.json.XML.toJSONObject(xmlString). > > I see at least the following things missing in the json generated by > XMLSerializer: > 1) the root element of the input xml is not included in the result json. > 2) My input xml text which has nothing to do with json syntax, has > multiple "<features>" nodes, all these nodes seems be omitted while > conversion. I tried the options mentioned at > http://sourceforge.net/tracker/index.php?func=detail&aid=1813520&group_id=171425&atid=857931without luck. > > I am I missing something with this relatively simple usecase? Thanks for > the help. > -polapali > > > -----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://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ> > |
From: Andres A. <aal...@ya...> - 2008-02-14 20:29:59
|
java.sql.Date is not supported by default, you'll have to register either JsonBeanProcessor or a JsonValueProcessorr depending on your needs. Processors are registered with JsonConfig. You may find more info at the following links http://json-lib.sourceforge.net/apidocs/jdk15/net/sf/json/processors/JsDateJsonBeanProcessor.html http://json-lib.sourceforge.net/xref-test/net/sf/json/TestJSONObjectWithProcessors.html http://json-lib.sourceforge.net/xref-test/net/sf/json/processors/TestJsDateJsonBeanProcessor.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: 刘远志 <liu...@gm...> To: jso...@li... Sent: Wednesday, February 13, 2008 5:29:39 PM Subject: [json-lib-user] error serializing java.sql.Date json-lib version 2.2.1 code: java.sql.Date d = new java.sql.Date(System.currentTimeMillis()); HashMap m = new HashMap(); m.put("date", d); JSONObject json = JSONObject.fromObject(m); output: Exception in thread "main" net.sf.json.JSONException: java.lang.reflect.InvocationTargetException at net.sf.json.JSONObject._fromBean(JSONObject.java:949) at net.sf.json.JSONObject.fromObject(JSONObject.java:189) at net.sf.json.JSONObject._processValue(JSONObject.java:2753) at net.sf.json.JSONObject._setInternal(JSONObject.java:2777) at net.sf.json.JSONObject.setValue(JSONObject.java:1503) at net.sf.json.JSONObject._fromMap(JSONObject.java:1280) at net.sf.json.JSONObject.fromObject(JSONObject.java:180) at net.sf.json.JSONObject.fromObject(JSONObject.java:151) at demo.JsonDate.main(JsonDate.java:24) Caused by: java.lang.reflect.InvocationTargetException at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25) at java.lang.reflect.Method.invoke(Method.java:597) at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod(PropertyUtilsBean.java:1773) at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(PropertyUtilsBean.java:1132) at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(PropertyUtilsBean.java:686) at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtilsBean.java:715) at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.java:290) at net.sf.json.JSONObject._fromBean(JSONObject.java:924) ... 8 more Caused by: java.lang.IllegalArgumentException at java.sql.Date.getHours(Date.java:143) ... 18 more -----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 ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping |
From: Andres A. <aal...@ya...> - 2008-02-14 20:16:08
|
Please send an snippet of your XML (a failing test would be better! =-)) Your report has little information that can be used to pinpoint the problem, thanks! 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: Sudharshan Pollapally <pol...@gm...> To: jso...@li... Sent: Wednesday, February 13, 2008 2:31:43 PM Subject: [json-lib-user] XMLSerializer usage for xml text to json conversion Hi, I am trying to use json-lib 2.2.1 XMLSerializer.read(xmlString) to convert xml text to json, similar to org.json.XML.toJSONObject(xmlString). I see at least the following things missing in the json generated by XMLSerializer: 1) the root element of the input xml is not included in the result json. 2) My input xml text which has nothing to do with json syntax, has multiple "<features>" nodes, all these nodes seems be omitted while conversion. I tried the options mentioned at http://sourceforge.net/tracker/index.php?func=detail&aid=1813520&group_id=171425&atid=857931 without luck. I am I missing something with this relatively simple usecase? Thanks for the help. -polapali -----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 ____________________________________________________________________________________ Looking for last minute shopping deals? Find them fast with Yahoo! Search. http://tools.search.yahoo.com/newsearch/category.php?category=shopping |
From: 刘. <liu...@gm...> - 2008-02-14 01:29:42
|
json-lib version 2.2.1 code: java.sql.Date d = new java.sql.Date(System.currentTimeMillis()); > HashMap m = new HashMap(); > m.put("date", d); > JSONObject json = JSONObject.fromObject(m); output: Exception in thread "main" net.sf.json.JSONException: > java.lang.reflect.InvocationTargetException > at net.sf.json.JSONObject._fromBean(JSONObject.java:949) > at net.sf.json.JSONObject.fromObject(JSONObject.java:189) > at net.sf.json.JSONObject._processValue(JSONObject.java:2753) > at net.sf.json.JSONObject._setInternal(JSONObject.java:2777) > at net.sf.json.JSONObject.setValue(JSONObject.java:1503) > at net.sf.json.JSONObject._fromMap(JSONObject.java:1280) > at net.sf.json.JSONObject.fromObject(JSONObject.java:180) > at net.sf.json.JSONObject.fromObject(JSONObject.java:151) > at demo.JsonDate.main(JsonDate.java:24) > Caused by: java.lang.reflect.InvocationTargetException > at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) > at sun.reflect.NativeMethodAccessorImpl.invoke( > NativeMethodAccessorImpl.java:39) > at sun.reflect.DelegatingMethodAccessorImpl.invoke( > DelegatingMethodAccessorImpl.java:25) > at java.lang.reflect.Method.invoke(Method.java:597) > at org.apache.commons.beanutils.PropertyUtilsBean.invokeMethod( > PropertyUtilsBean.java:1773) > at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty( > PropertyUtilsBean.java:1132) > at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty( > PropertyUtilsBean.java:686) > at org.apache.commons.beanutils.PropertyUtilsBean.getProperty( > PropertyUtilsBean.java:715) > at org.apache.commons.beanutils.PropertyUtils.getProperty( > PropertyUtils.java:290) > at net.sf.json.JSONObject._fromBean(JSONObject.java:924) > ... 8 more > Caused by: java.lang.IllegalArgumentException > at java.sql.Date.getHours(Date.java:143) > ... 18 more > |
From: Sudharshan P. <pol...@gm...> - 2008-02-13 22:31:46
|
Hi, I am trying to use json-lib 2.2.1 XMLSerializer.read(xmlString) to convert xml text to json, similar to org.json.XML.toJSONObject(xmlString). I see at least the following things missing in the json generated by XMLSerializer: 1) the root element of the input xml is not included in the result json. 2) My input xml text which has nothing to do with json syntax, has multiple "<features>" nodes, all these nodes seems be omitted while conversion. I tried the options mentioned at http://sourceforge.net/tracker/index.php?func=detail&aid=1813520&group_id=171425&atid=857931without luck. I am I missing something with this relatively simple usecase? Thanks for the help. -polapali |
From: Andres A. <aal...@ya...> - 2008-02-13 16:44:15
|
You are missing on last piece of info, the classifier. Json-lib comes in two flavors: jdk3 and jdk5 so you need to specify which version you need. The following should work for jdk5 <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.2</version> <classifier>jdk5</classifier> </dependency> 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: Thinkboy <man...@gm...> To: jso...@li... Sent: Wednesday, February 13, 2008 2:27:18 AM Subject: [json-lib-user] error while retrieving jar from maven2 hi, I set up json-lib dependency in my maven2 pom.xml as the following: <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.2</version> </dependency> however, I received the following error. pls advse. [INFO] artifact org.apache.maven.plugins:maven-resources-plugin: checking for updates from central Downloading: http://repo1.maven.org/maven2/net/sf/json-lib/json-lib/2.2/json-lib-2.2.jar [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Failed to resolve artifact. Missing: ---------- 1) net.sf.json-lib:json-lib:jar:2.2 Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=net.sf.json-lib - DartifactId=json-lib -Dversion=2.2 -Dpackaging=jar -Dfile=/path/to/file Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=net.sf.json-lib - DartifactId=json-lib -Dversion=2.2 -Dpackaging=jar -Dfile=/path/to/ file -Durl=[url] -DrepositoryId=[id] Path to dependency: 1) com.mydomain:myapp:jar:1.0 2) net.sf.json-lib:json-lib:jar:2.2 ---------- 1 required artifact is missing. .... ------------------------------------------------------------------------- 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 ____________________________________________________________________________________ Never miss a thing. Make Yahoo your home page. http://www.yahoo.com/r/hs |
From: Thinkboy <man...@gm...> - 2008-02-13 10:27:27
|
hi, I set up json-lib dependency in my maven2 pom.xml as the following: <dependency> <groupId>net.sf.json-lib</groupId> <artifactId>json-lib</artifactId> <version>2.2</version> </dependency> however, I received the following error. pls advse. [INFO] artifact org.apache.maven.plugins:maven-resources-plugin: checking for updates from central Downloading: http://repo1.maven.org/maven2/net/sf/json-lib/json-lib/2.2/json-lib-2.2.jar [INFO] ------------------------------------------------------------------------ [ERROR] BUILD ERROR [INFO] ------------------------------------------------------------------------ [INFO] Failed to resolve artifact. Missing: ---------- 1) net.sf.json-lib:json-lib:jar:2.2 Try downloading the file manually from the project website. Then, install it using the command: mvn install:install-file -DgroupId=net.sf.json-lib - DartifactId=json-lib -Dversion=2.2 -Dpackaging=jar -Dfile=/path/to/file Alternatively, if you host your own repository you can deploy the file there: mvn deploy:deploy-file -DgroupId=net.sf.json-lib - DartifactId=json-lib -Dversion=2.2 -Dpackaging=jar -Dfile=/path/to/ file -Durl=[url] -DrepositoryId=[id] Path to dependency: 1) com.mydomain:myapp:jar:1.0 2) net.sf.json-lib:json-lib:jar:2.2 ---------- 1 required artifact is missing. .... |
From: Manos B. <man...@ge...> - 2008-02-13 10:13:47
|
Hello Andres, Andres Almiray wrote: > 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). Many thanks, this is "go" enough for me :-) Cheers, Manos |
From: Horst G. <ze...@ze...> - 2008-02-12 19:37:40
|
OK thanks you :-) The problem is, that this property wasn't even part of the original model bean but was probably added by Hibernate due to some ForeignKey (or something similar) in a matter that probably makes it a write-only property (no getter). Currently I just solved this by explicitly creating the JSONObject and filling it but I will definitely look again into the property filters and processors during the refactoring which is soooo sure to come :-) Thank you, Horst On Feb 12, 2008 8:02 PM, Andres Almiray <aal...@ya...> wrote: > > Hi Horst, > > It may be, but depends on what you want to accomplish. If that property > should not be serialized > then you can exclude it by using the property exclusion mechanism or > registering a property Filter. > Filters can be registered from Java to Json and from Json to Java in a > separate way for your > convenience. > > The Json[Bean|Value]ProcessorMatchers give you more control over which > processor will be triggered > based on class/subclass types or any other match strategy 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: Horst Gutmann <ze...@ze...> > To: Andres Almiray <aal...@ya...> > Cc: jso...@li... > Sent: Tuesday, February 12, 2008 10:57:41 AM > Subject: Re: [json-lib-user] Hibernate Beans > > Hi :-) > > On some hibernated beans (couldn't yet completely trace it) I get a > problem with the property "delegate" (which seems to come out of > Hibernate's fiddling with the beans) has no getter. Is this somehow > related? > > Best regards, Horst > > On Feb 12, 2008 6:45 PM, Andres Almiray <aal...@ya...> wrote: > > > > 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 > > > > > > ________________________________ > > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > > now. > > ------------------------------------------------------------------------- > > 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. |
From: Andres A. <aal...@ya...> - 2008-02-12 19:02:33
|
Hi Horst, It may be, but depends on what you want to accomplish. If that property should not be serialized then you can exclude it by using the property exclusion mechanism or registering a property Filter. Filters can be registered from Java to Json and from Json to Java in a separate way for your convenience. The Json[Bean|Value]ProcessorMatchers give you more control over which processor will be triggered based on class/subclass types or any other match strategy 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: Horst Gutmann <ze...@ze...> To: Andres Almiray <aal...@ya...> Cc: jso...@li... Sent: Tuesday, February 12, 2008 10:57:41 AM Subject: Re: [json-lib-user] Hibernate Beans Hi :-) On some hibernated beans (couldn't yet completely trace it) I get a problem with the property "delegate" (which seems to come out of Hibernate's fiddling with the beans) has no getter. Is this somehow related? Best regards, Horst On Feb 12, 2008 6:45 PM, Andres Almiray <aal...@ya...> wrote: > > 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 > > > ________________________________ > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > now. > ------------------------------------------------------------------------- > 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 > > ____________________________________________________________________________________ Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ |
From: Horst G. <ze...@ze...> - 2008-02-12 18:57:46
|
Hi :-) On some hibernated beans (couldn't yet completely trace it) I get a problem with the property "delegate" (which seems to come out of Hibernate's fiddling with the beans) has no getter. Is this somehow related? Best regards, Horst On Feb 12, 2008 6:45 PM, Andres Almiray <aal...@ya...> wrote: > > 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 > > > ________________________________ > Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it > now. > ------------------------------------------------------------------------- > 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 > > |