json-lib-user Mailing List for Json-lib (Page 11)
Brought to you by:
aalmiray
You can subscribe to this list here.
2006 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(6) |
Sep
(5) |
Oct
(1) |
Nov
(7) |
Dec
(5) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2007 |
Jan
(4) |
Feb
(5) |
Mar
(1) |
Apr
|
May
(11) |
Jun
(3) |
Jul
(12) |
Aug
(4) |
Sep
(8) |
Oct
(11) |
Nov
(7) |
Dec
(30) |
2008 |
Jan
(11) |
Feb
(15) |
Mar
(8) |
Apr
|
May
(9) |
Jun
(21) |
Jul
(1) |
Aug
(4) |
Sep
(1) |
Oct
|
Nov
(3) |
Dec
(8) |
2009 |
Jan
(6) |
Feb
(1) |
Mar
(3) |
Apr
(5) |
May
(10) |
Jun
(3) |
Jul
(1) |
Aug
|
Sep
(4) |
Oct
(1) |
Nov
(1) |
Dec
(1) |
2010 |
Jan
|
Feb
(2) |
Mar
(2) |
Apr
(3) |
May
(5) |
Jun
(1) |
Jul
|
Aug
(4) |
Sep
|
Oct
(1) |
Nov
(4) |
Dec
|
2011 |
Jan
|
Feb
(1) |
Mar
(1) |
Apr
|
May
|
Jun
(3) |
Jul
|
Aug
(1) |
Sep
|
Oct
|
Nov
(8) |
Dec
|
2012 |
Jan
|
Feb
|
Mar
(4) |
Apr
|
May
(1) |
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(1) |
Jun
(1) |
Jul
|
Aug
|
Sep
|
Oct
(1) |
Nov
|
Dec
|
2014 |
Jan
(1) |
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2017 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
(2) |
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: Andres A. <aal...@ya...> - 2007-03-31 18:52:46
|
Dear Json-lib Users, =0AI'm pleased to announce that Json-lib version 1.1 = has been released. =0A =0AChangelog: =0A =0A+ Updates:=0AUpdated FAQ and = Getting Started guide.=0APromoted length() to JSON interface.=0A=0A+ Additi= ons:=0AAdded NoopJavaIdentifierTransformer and made it the default (perform= s no conversion)=0A=0A+ Fixes:=0A=0A1684034 Allow transformation of key val= ues to proper Java identifier.=0A1656551 Upgrade XML support.=0A1679986 Ski= p type information when writing XML.=0A1679985 Move child properties to par= ent when writing XML.=0A1679982 Allow parsing of duplicate properties.=0A16= 90942 XMLSerializer can not handle namespace declarations.=0A1690941 [Regre= ssion] toBean() fails with namespaced properties.=0A=0A=0A=09=0A=09=0A=09= =09=0A___________________________________________________________ =0ADo You= Yahoo!? =0ALa mejor conexi=F3n a Internet y <b >2GB</b> extra a tu correo = por $100 al mes. http://net.yahoo.com.mx =0A |
From: Andres A. <aal...@ya...> - 2007-02-22 17:31:03
|
Hi Spiros,=0A=0AJson-lib-jdk13 will work from jdk1.3.1 and upwards=0AJson-l= ib-jdk15 will work from jdk1.5 and upwards=0A=0AIn your case, you'll have t= o use the jdk13 jar.=0AI guess Eclipse complained because the jar you choos= ed was compiled with target=3D1.5=0Ameaning that the class format is not re= adable by 1.4 jvms.=0APlease take a moment to read the Introduction, Gettin= g Started and Faq pages to get=0Amore information on the library.=0A=0AOne = last thing, as a former teacher, I've never believed in stupid questions :-= )=0A=0ACheers,=0AAndres=0A=0A-------------------------------------------=0A= http://jroller.com/page/aalmiray=0A--=0AWhat goes up, must come down. Ask a= ny system administrator.=0AThere are 10 types of people in the world: Those= who understand binary, and those who don't.=0ATo understand recursion, we = must first understand recursion.=0A=0A----- Mensaje original ----=0ADe: Spi= ros Papadopoulos <sp...@go...>=0APara: jso...@li...urce= forge.net=0AEnviado: jueves, 22 de febrero, 2007 11:23:12=0AAsunto: [json-l= ib-user] Json-lib and jdk 1.4=0A=0AHi,=0A=0A =0A=0AI just decided to use JS= ON for the first time. I found JSON-lib and In the download page =0A=0Ait h= as only json-lib-jdk1.3 and json-lib-jdk1.5. Is it not compatible with jdk= 1.4???=0A=0A =0A=0AAt first i tried without thinking at all and included th= e jdk1.5 in my app but then =0A=0Aeclipse was complaining about the "net." = part of the import net.sf.json.JSONObject;=0A=0AJDK 1.4.2 is used with the = project i am working on.=0A=0A =0A=0AAm i talking non sense? Accept my apol= ogies if this is something stupid or obvious, =0A=0Abut i am new to this.= =0A=0AThanks in advance=0A=0ASpiros P. =0A=0A------------------------------= -------------------------------------------=0ATake Surveys. Earn Cash. Infl= uence the Future of IT=0AJoin SourceForge.net's Techsay panel and you'll ge= t the chance to share your=0Aopinions on IT & business topics through brief= surveys-and earn cash=0Ahttp://www.techsay.com/default.php?page=3Djoin.php= &p=3Dsourceforge&CID=3DDEVDEV=0A___________________________________________= ____=0Ajson-lib-user mailing list=0Aj...@li...=0Ah= ttps://lists.sourceforge.net/lists/listinfo/json-lib-user=0A=0A=0A=0A=0A=0A= =0A=0A=09=0A=09=0A=09=09=0A________________________________________________= ___________ =0ADo You Yahoo!? =0ALa mejor conexi=F3n a Internet y <b >2GB</= b> extra a tu correo por $100 al mes. http://net.yahoo.com.mx =0A |
From: Spiros P. <sp...@go...> - 2007-02-22 17:23:22
|
Hi, I just decided to use JSON for the first time. I found JSON-lib and In the download page it has only json-lib-jdk1.3 and json-lib-jdk1.5. Is it not compatible with jdk1.4??? At first i tried without thinking at all and included the jdk1.5 in my app but then eclipse was complaining about the "net." part of the import net.sf.json.JSONObject; JDK 1.4.2 is used with the project i am working on. Am i talking non sense? Accept my apologies if this is something stupid or obvious, but i am new to this. Thanks in advance Spiros P. |
From: Andres A. <aal...@ya...> - 2007-02-12 17:50:16
|
=0ADear Json-lib users, =0A=0AI'm pleased to announce that Json-lib versi= on 1.0 has been released. =0AThanks to everybody that suggested bugs, fea= tures, comments and tests.=0A=0A =0A=0AChangelog: =0A=0A =0A=0A+ Update= s =0A=0ARemoved deprecated classes. =0A=0A =0A=0A+ Fixes: =0A=0A1650535. S= tring property incorrectly parsed as an array.=0A=0A=0A=09=0A=09=0A=09=09= =0A___________________________________________________________ =0ADo You Ya= hoo!? =0ALa mejor conexi=F3n a Internet y <b >2GB</b> extra a tu correo por= $100 al mes. http://net.yahoo.com.mx =0A |
From: Andres A. <aal...@ya...> - 2007-02-02 16:55:41
|
Hi Elizabeth,=0A=0AAnother user also registered this issue in the bug datab= ase,=0Ahttp://sourceforge.net/tracker/index.php?func=3Ddetail&aid=3D1650535= &group_id=3D171425&atid=3D857928=0AI'm currently looking at it, I'll see wh= at I can do :-)=0A=0ARegards,=0AAndres=0A =0A------------------------------= -------------=0Ahttp://jroller.com/page/aalmiray=0A--=0AWhat goes up, must = come down. Ask any system administrator.=0AThere are 10 types of people in = the world: Those who understand binary, and those who don't.=0ATo understan= d recursion, we must first understand recursion.=0A=0A----- Mensaje origina= l ----=0ADe: Elizabeth Keogh <ek...@th...>=0APara: json-lib-use= r...@li...=0AEnviado: jueves, 1 de febrero, 2007 10:01:34=0AAs= unto: [json-lib-user] Square brackets in strings=0A=0ADear Json-lib devs,= =0A=0AThank you for your library! It's served us very well for the past few= months.=0A=0AUnfortunately my customers have started putting square bracke= ts just like the example below=0Ain the text they're sending us, with the e= xception that results (from info3).=0A=0A=0A public void testThatJsonIsN= otConfusedBySquareBrackets() {=0A HashMap<String, String> map =3D ne= w HashMap<String, String>();=0A map.put("address", "1 The flats [Upp= er floor]");=0A map.put("phoneNumber", "[+44] 582 401923");=0A = map.put("info1", "[Likes coffee]");=0A map.put("info2", "[Likes co= ffee] [Likes tea]");=0A map.put("info3", "[Likes coffee [but not wit= h sugar]]");=0A =0A JSONObject json =3D JSONObject.fromObject= (map);=0A }=0A=0A Due to the intrigues of multiple departments all using= this data, there's little to no chance of stopping them.=0A=0A=0A=0ACan yo= u help?=0A=0AThe problem seems as though it might be here, in JSONUtils:=0A= =0A public static boolean mayBeJSON( String string )=0A {=0A retur= n string !=3D null=0A && ("null".equalsIgnoreCase( string )=0A = || (string.startsWith( "[" ) && string.endsWith( "]" )) || = (string.startsWith( "{" ) && string.endsWith( "}" )));=0A }=0A=0AIs there= any chance please of fixing this, eg: by replacing the above with a regula= r expression that checks the String is truly JSON?=0A=0AMany thanks,=0ALiz.= =0A=0A--=0AElizabeth Keogh=0A...@th...=0Ahttp://www.livejournal.= com/users/sirenian=0A=0A=0A=0A---------------------------------------------= ----------------------------=0AUsing Tomcat but need to do more? Need to su= pport web services, security?=0AGet stuff done quickly with pre-integrated = technology to make your job easier.=0ADownload IBM WebSphere Application Se= rver v.1.0.1 based on Apache Geronimo=0Ahttp://sel.as-us.falkag.net/sel?cmd= =3Dlnk&kid=3D120709&bid=3D263057&dat=3D121642=0A___________________________= ____________________=0Ajson-lib-user mailing list=0Aj...@li...u= rceforge.net=0Ahttps://lists.sourceforge.net/lists/listinfo/json-lib-user= =0A=0A=0A=0A=0A=0A=0A=0A=09=0A=09=0A=09=09=0A______________________________= _____________________________ =0ADo You Yahoo!? =0ALa mejor conexi=F3n a In= ternet y <b >2GB</b> extra a tu correo por $100 al mes. http://net.yahoo.co= m.mx =0A |
From: Elizabeth K. <ek...@th...> - 2007-02-01 16:04:36
|
<div>Dear Json-lib devs,<br><br>Thank you for your library! It's served us = very well for the past few months.<br><br>Unfortunately my customers have s= tarted putting square brackets just like the example below in the text they're sending us, with the exception that results (from info3= ).<br> <br> public void testThatJsonIsNotConfusedBySquareBracket= s() {<br> HashMap<String, String>= ; map =3D new HashMap<String, String>();<br> = map.put("address", "1 The flats [Upper floor]");<br> &nbs= p; map.put("phoneNumber", "[+44] 582 401923");<br>= map.put("info1", "[Likes coffee]");<b= r> map.put("info2", "[Likes coffee] [L= ikes tea]");<br> map.put("info3", "[Li= kes coffee [but not with sugar]]");<br>  = ; <br> JSONObject json =3D JSONObject.= fromObject(map);<br> }<br><br> Due to the intrigues of mu= ltiple departments all using this data, there's little to no chance of stop= ping them.<br> <br> Can you help?<br><br>The problem seems as though it might be here, in JSONU= tils:<br><br> public static boolean mayBeJSON( String string )<= br> {<br> return string !=3D null= <br> &= ;& ("null".equalsIgnoreCase( string )<br> = ||= (string.startsWith( "[" ) && string.endsWith( "]" )) || (string.st= artsWith( "{" ) && string.endsWith( "}" )));<br> }<br><= br>Is there any chance please of fixing this, eg: by replacing the above wi= th a regular expression that checks the String is truly JSON?<br><br>Many t= hanks,<br>Liz.<br><br><div>--<br>Elizabeth Keogh<br><a href=3D"mailto:= li...@th...">li...@th...</a><br><a href=3D"http://www.liv= ejournal.com/users/sirenian">http://www.livejournal.com/users/sirenian</a><= br></div></div>= |
From: Andres A. <aal...@ya...> - 2007-01-31 16:45:22
|
Venkatesh,=0A=0AYou may use the JSONSerializer, which will convert automati= cally Beans, Maps, DynaBeans to JSONObject;=0Aarrays and Collections to JSO= NArray and nulls to JSONNull.=0A=0AIn the case of using a Number or Boolean= as a parameter, it will return an empty JSONObject, because there is no=0A= property name involved, just the value. On the other hand if you call JSONA= rray.fromObject() directly with these values,=0Athe the result will be a JS= ONArray with one element.=0A=0AI hope this helps.=0A=0ACheers,=0AAndres=0A = =0A-------------------------------------------=0Ahttp://jroller.com/page/aa= lmiray=0A--=0AWhat goes up, must come down. Ask any system administrator.= =0AThere are 10 types of people in the world: Those who understand binary, = and those who don't.=0ATo understand recursion, we must first understand re= cursion.=0A=0A----- Mensaje original ----=0ADe: Venkatesh Babu <venkatbabuk= r...@gm...>=0APara: jso...@li...=0AEnviado: lunes, = 29 de enero, 2007 19:24:42=0AAsunto: [json-lib-user] Info about a generic m= ethod to convert any object to JSON=0A=0AHi All,=0A=0AI have a question rel= ated to json-lib. Request some knowledgeable person to answer the same.=0A= =0ADoes the library have a generic method that returns JSON for any one of = the java object from the list below:=0A=0Alist of types that can be passed:= Map, List, Number, Boolean, String, array.=0A=0AThe reason I'm asking t= his question is - it seems like for maps, arrays and list objects we can us= e JSONObject.fromObject(), but for types like Number, Boolean, String we ha= ve to use =0AJSONUtils.valueToString() . So, I was wondering if I have to w= rite a wrapper function above these two, so that I can get a generic functi= on that has to check if the object passed is Map, List, array or rest and c= all suitable functions.=0A=0A=0AThank you,=0AVenkatesh=0A=0A=0A------------= -------------------------------------------------------------=0ATake Survey= s. Earn Cash. Influence the Future of IT=0AJoin SourceForge.net's Techsay p= anel and you'll get the chance to share your=0Aopinions on IT & business to= pics through brief surveys - and earn cash=0Ahttp://www.techsay.com/default= .php?page=3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV=0A_______________________= ________________________=0Ajson-lib-user mailing list=0Ajson-lib-user@lists= .sourceforge.net=0Ahttps://lists.sourceforge.net/lists/listinfo/json-lib-us= er=0A=0A=0A=0A=0A=0A=0A=0A=09=0A=09=0A=09=09=0A____________________________= _______________________________ =0ADo You Yahoo!? =0ALa mejor conexi=F3n a = Internet y <b >2GB</b> extra a tu correo por $100 al mes. http://net.yahoo.= com.mx =0A |
From: Venkatesh B. <ven...@gm...> - 2007-01-30 01:24:45
|
Hi All, I have a question related to json-lib. Request some knowledgeable person to answer the same. Does the library have a generic method that returns JSON for any one of the java object from the list below: list of types that can be passed: Map, List, Number, Boolean, String, array. The reason I'm asking this question is - it seems like for maps, arrays and list objects we can use JSONObject.fromObject(), but for types like Number, Boolean, String we have to use JSONUtils.valueToString() . So, I was wondering if I have to write a wrapper function above these two, so that I can get a generic function that has to check if the object passed is Map, List, array or rest and call suitable functions. Thank you, Venkatesh |
From: Andres A. <aal...@ya...> - 2007-01-20 17:51:44
|
Dear Json-lib Users=0A=0AI'm pleased to announce that Json-lib version 1.0b= 2 has been released. =0AThis should be the last release before the 1.0 fin= al, I kindly encourage=0Aeveryone to submit any bugs you may find as quickl= y as possible. =0AFeature requests are accepted also, but they'll pushed fo= r the 2.0 release cycle=0A =0AJSON-lib is a java library for transforming b= eans, maps and XML to JSON and back again to beans and DynaBeans. It is bas= ed on the work by Douglas Crockford in http://www.json.org/java. =0A =0ACh= angelog: =0A=0AUpdates:=0A + Updated javadocs.=0A + Moved interface JSONTy= pes to net.sf.json.xml=0A + Deprecated JSONDynaBean, JSONDynaClass & DynaBe= anToBeanMorpher. =0A Use MorphDynaBean, MorphDynaClass & BeanMorpher fro= m EZMorph instead.=0A + Removed net.sf.json.util.CDL, repeated functionalit= y.=0A=0AFixes:=0A 163589: JSONDynaBean nested arrays not treated as an arra= y. Test provided by arco.vandenheuvel[at]points[dot]com =0A 1630742: JSONAr= ray does not transforms byte[], short[] and long[]=0A 1630736: JSONArray is= missing validation on float[] and double[]=0A 1630258: Validate ECMAScript= max & min Number values. (rolled-back)=0A 1622676: JSONArray. put does not= use excludes.=0A 1622675: JSONObject.put does not use excludes.=0A 1622674= : JSONArray does not pass excludes.=0A=0A=0A=0A=0A=09=0A=09=0A=09=09=0A____= _______________________________________________________ =0ADo You Yahoo!? = =0ALa mejor conexi=F3n a Internet y <b >2GB</b> extra a tu correo por $100 = al mes. http://net.yahoo.com.mx =0A |
From: Andres A. <aal...@ya...> - 2007-01-06 18:43:42
|
Hi all,=0A=0AJson-lib has reached the maturity level for the 1.0 release, I= kindly encourage everybody to=0Adownload and test version1.0b1, released 3= weeks ago, or build their own distribution=0Aright from the cvs. The focus= on the next 1-2 weeks will be only to fix bugs and update=0Athe docs.=0A= =0AYour feedback is always welcomed :-)=0A =0AAndres=0A=0A-----------------= --------------------------=0Ahttp://jroller.com/page/aalmiray=0A--=0AWhat g= oes up, must come down. Ask any system administrator.=0AThere are 10 types = of people in the world: Those who understand binary, and those who don't.= =0ATo understand recursion, we must first understand recursion.=0A=0A______= ____________________________________________=0ACorreo Yahoo!=0AEspacio para= todos tus mensajes, antivirus y antispam =A1gratis! =0AReg=EDstrate ya - h= ttp://correo.yahoo.com.mx/ |
From: Andres A. <aal...@ya...> - 2006-12-18 23:17:55
|
=0ADear Json-lib Users, =0A=0A=0AI'm pleased to announce that Json-lib vers= ion 1.0b1 has been released. =0A=0A =0A=0AChangelog: =0A=0A =0A=0AAdditio= ns: =0A=0A Added JSONAssert for easy JSON testing. =0A=0A =0A=0AUpdates: = =0A=0A Updated JSONFunction constructor for correct length of parameters. = =0A=0A Updated javadocs and site docs. =0A=0A Only default constructors are= public (JSONObject & JSONArray). =0A=0A Class objects are converted to Str= ings (toJSON) and back (toJava). =0A=0A =0A=0AFixes: =0A=0A 1614276 Skip a = property without write method. =0A=0A 1614275 Skip a property without read = method. =0A=0A 1614273 Annotation should not be transformed. =0A=0A 1614278= Change IAEs for JSONException. =0A=0A 1613402 JSONObject tries to access E= num.getDeclaringClass (). =0A=0A 1611204 Inspect property's value type in f= actory methods. =0A=0A 1610979 Support different encodings on XmlSerializer= . =0A=0A 1608212 JSONDynaClass allows multidimensional arrays. =0A=0A 16074= 48 Primitives support for JSONDynaBean. =0A=0A 1557286 Support Java 1.5 Enu= m in JSONObject and JSONArray. =0A=0A 1606609 JDK 1.3 RuntimeException is n= ot nestable. =0A=0A 1602386 Add printer friendly methods to JSON interface.= =0A=0A 1596168 JSONArray fails to convert an array of BigDecimals/BigInteg= er. =0A=0A 1592799 Nested Lists were not handled properly in JSONObject.toB= ean()=0A=0A=0A=0A__________________________________________________=0ACorre= o Yahoo!=0AEspacio para todos tus mensajes, antivirus y antispam =A1gratis!= =0AReg=EDstrate ya - http://correo.yahoo.com.mx/ |
From: Andres A. <aal...@ya...> - 2006-12-08 00:07:36
|
Hi Janardhanan,=0A=0AHere is what's happening:=0AYou are using "Object" as = a "catch-all" type for your property, when the JSONObject.fromObject() stat= ic factories get called=0Afrom the JSONSerializer, it inspects the properti= es of the input object (IssueObject) by type and determines that the proper= ty=0A'value' must be converted to a JSONObject, following the chain it find= s out its a String, but because the original command=0Awas to build a JSONO= bject and your String value does not begin with a "{" and exception is thro= wn.=0AAn exception should be thrown too if instead of a String you use a Nu= mber, Array, Collection or Boolean.=0A=0AThe solution would be to inspect t= he property's value for a more specific type, once the factory method has r= eached the conclusion=0Athat the type is "Object" and before it calls fromO= bject() again. AS you may foresee this is not an easy change and will take = a=0Acouple of days, I'll register this as a Feature Request (as I consider = that inspection by type is correct), please keep an eye on the=0Aproject's = tracker to find out when the change is on the cvs.=0A=0ARegards,=0AAndres= =0A =0A-------------------------------------------=0Ahttp://jroller.com/pag= e/aalmiray=0A--=0AWhat goes up, must come down. Ask any system administrato= r.=0AThere are 10 types of people in the world: Those who understand binary= , and those who don't.=0ATo understand recursion, we must first understand = recursion.=0A=0A----- Original Message ----=0AFrom: Janardhanan Vembunaraya= nan <jve...@gm...>=0ATo: jso...@li...=0ASent: = Wednesday, December 6, 2006 5:29:53 PM=0ASubject: [json-lib-user] JSON Lib = Issue=0A=0AHi,=0A=0A =0A=0A I am trying to use JSON in our current project= and when I try to run the following program I am getting the following err= or given below. The sample code is also given below. When the property is o= f type Object then I am getting this error. When I change the type from Obj= ect to String it works fine. But I need to the type be Object for our requi= rement.=0A=0A=0A =0A=0A=0AException in thread "main" net.sf.json.JSONExcept= ion: A JSONObject text must begin with '{' at character 1 of json=0A at net= .sf.json.util.JSONTokener.syntaxError(JSONTokener.java=0A:502)=0A at net.sf= .json.JSONObject.<init>(JSONObject.java:660)=0A at net.sf.json.JSONObject.<= init>(JSONObject.java:839)=0A at net.sf.json.JSONObject.fromString(JSONObje= ct.java:260)=0A at net.sf.json.JSONObject.fromObject=0A(JSONObject.java:239= )=0A at net.sf.json.JSONObject.setValue(JSONObject.java:533)=0A at net.sf.j= son.JSONObject.fromBean(JSONObject.java:162)=0A at net.sf.json.JSONObject.f= romObject(JSONObject.java:246)=0A at net.sf.json.JSONArray.fromObject=0A(JS= ONArray.java:199)=0A at net.sf.json.JSONSerializer.toJSON(JSONSerializer.ja= va:63)=0A at com.debug.JSONIssue.constructJSONFromObject(JSONIssue.java:15)= =0A at com.debug.JSONIssue.main(JSONIssue.java:11)=0A =0A=0A=0A=0A=0Apackag= e com.debug;=0A=0Aimport net.sf.json.JSON;=0Aimport net.sf.json.JSONSeriali= zer;=0A=0Apublic class JSONIssue {=0A=0A public static void main(String arg= s[]) throws Exception{=0A IssueObject o =3D new IssueObject();=0A o.setVa= lue("json");=0A System.out.println(constructJSONFromObject(o));=0A=0A=0A }= =0A private static JSON constructJSONFromObject(IssueObject o) throws Excep= tion {=0A return JSONSerializer.toJSON(o);=0A }=0A=0A}=0A=0A=0Apackage com= .debug;=0A=0Apublic class IssueObject {=0A private Object value;=0A =0A pub= lic IssueObject(){=0A }=0A=0A public Object getValue() {=0A return value;= =0A }=0A =0A public void setValue(Object value) {=0A this.value =3D value;= =0A }=0A}=0A=0A=0A=0A =0A=0A =0A=0ARegards,=0A=0AJana=0A=0A----------------= ---------------------------------------------------------=0ATake Surveys. E= arn Cash. Influence the Future of IT=0AJoin SourceForge.net's Techsay panel= and you'll get the chance to share your=0Aopinions on IT & business topics= through brief surveys - and earn cash=0Ahttp://www.techsay.com/default.php= ?page=3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV=0A___________________________= ____________________=0Ajson-lib-user mailing list=0Aj...@li...u= rceforge.net=0Ahttps://lists.sourceforge.net/lists/listinfo/json-lib-user= =0A=0A=0A=0A=0A=0A=0A=0A=09=0A=09=0A=09=09=0A______________________________= _____________________________ =0ADo You Yahoo!? =0ALa mejor conexi=F3n a In= ternet y <b >2GB</b> extra a tu correo por $100 al mes. http://net.yahoo.co= m.mx =0A |
From: Andres A. <aal...@ya...> - 2006-12-07 17:42:05
|
Hi Mathew,=0A=0ACurrently there is no way to specify a different encoding o= ther that UTF-8, I'll add it as=0Aa feature request to the issue tracker.= =0ARegarding the namespace support, can you send an example of what you are= expecting,=0Aa testcase would be even better ;)=0A=0ACheers.=0AAndres=0A = =0A-------------------------------------------=0Ahttp://jroller.com/page/aa= lmiray=0A--=0AWhat goes up, must come down. Ask any system administrator.= =0AThere are 10 types of people in the world: Those who understand binary, = and those who don't.=0ATo understand recursion, we must first understand re= cursion.=0A=0A----- Original Message ----=0AFrom: Young Matthew <matthew.yo= un...@fo...>=0ATo: jso...@li...=0ASent:= Thursday, December 7, 2006 8:15:02 AM=0ASubject: [json-lib-user] ISO-8859-= 1 encoding with XMLSerializer (to JSONArray)=0A=0A=0A=0A =0A=0Ahej,=0A=0A = =0A=0AHave XML document =0Athat uses ISO-8859-1 encoding which I need to pa= ss off to the =0AXMLSerializer. Must be a way to state the encoding to JSO= N lib. Plus =0AI am assuming that XMLSerializer handles namespaces (have u= sed json-lib for =0Amaybe 2 hours).=0A=0A =0A=0A =0A=0A/ =0Amatthew=0A-----= --------------------------------------------------------------------=0ATake= Surveys. Earn Cash. Influence the Future of IT=0AJoin SourceForge.net's Te= chsay panel and you'll get the chance to share your=0Aopinions on IT & busi= ness topics through brief surveys - and earn cash=0Ahttp://www.techsay.com/= default.php?page=3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV=0A________________= _______________________________=0Ajson-lib-user mailing list=0Ajson-lib-use= r...@li...=0Ahttps://lists.sourceforge.net/lists/listinfo/json= -lib-user=0A=0A=0A=0A=0A=0A=0A=0A=09=0A=09=0A=09=09=0A_____________________= ______________________________________ =0ADo You Yahoo!? =0ALa mejor conexi= =F3n a Internet y <b >2GB</b> extra a tu correo por $100 al mes. http://net= .yahoo.com.mx =0A |
From: Young M. <mat...@fo...> - 2006-12-07 14:15:33
|
hej, =20 Have XML document that uses ISO-8859-1 encoding which I need to pass off to the XMLSerializer. Must be a way to state the encoding to JSON lib. Plus I am assuming that XMLSerializer handles namespaces (have used json-lib for maybe 2 hours). =20 =20 / matthew |
From: Janardhanan V. <jve...@gm...> - 2006-12-06 23:30:00
|
Hi, I am trying to use JSON in our current project and when I try to run the following program I am getting the following error given below. The sample code is also given below. When the property is of type Object then I am getting this error. When I change the type from Object to String it works fine. But I need to the type be Object for our requirement. Exception in thread "main" net.sf.json.JSONException: A JSONObject text must begin with '{' at character 1 of json at net.sf.json.util.JSONTokener.syntaxError(JSONTokener.java:502) at net.sf.json.JSONObject.<init>(JSONObject.java:660) at net.sf.json.JSONObject.<init>(JSONObject.java:839) at net.sf.json.JSONObject.fromString(JSONObject.java:260) at net.sf.json.JSONObject.fromObject(JSONObject.java:239) at net.sf.json.JSONObject.setValue(JSONObject.java:533) at net.sf.json.JSONObject.fromBean(JSONObject.java:162) at net.sf.json.JSONObject.fromObject(JSONObject.java:246) at net.sf.json.JSONArray.fromObject(JSONArray.java:199) at net.sf.json.JSONSerializer.toJSON(JSONSerializer.java:63) at com.debug.JSONIssue.constructJSONFromObject(JSONIssue.java:15) at com.debug.JSONIssue.main(JSONIssue.java:11) package com.debug; import net.sf.json.JSON; import net.sf.json.JSONSerializer; public class JSONIssue { public static void main(String args[]) throws Exception{ IssueObject o = new IssueObject(); o.setValue("json"); System.out.println(constructJSONFromObject(o)); } private static JSON constructJSONFromObject(IssueObject o) throws Exception { return JSONSerializer.toJSON(o); } } package com.debug; public class IssueObject { private Object value; public IssueObject(){ } public Object getValue() { return value; } public void setValue(Object value) { this.value = value; } } Regards, Jana |
From: Andres A. <aal...@ya...> - 2006-11-29 16:17:12
|
Hi Rashmi,=0A=0AYour changes seem to be ok, but if I think BigInteger shoul= d be supported as well.=0AThis feature already has been requested as "JSONA= rray fails to convert an array of BigDecimals"=0Ahttp://sourceforge.net/tra= cker/index.php?func=3Ddetail&aid=3D1596168&group_id=3D171425&atid=3D857928= =0A=0AThe code is already on the cvs and includes an update on ezmorph-0.9.= 1 =0A(hint: BigIntegerMorpher and BigDecimalMorpher). The release of ezmorp= h will be in a couple of hours,=0Aafter that you may download the latest sn= apshot from json-lib's cvs.=0A =0ACheers.=0A=0A=0A-------------------------= ------------------=0AIng. Andres Almiray Jaramillo=0Ahttp://jroller.com/pag= e/aalmiray=0A--=0AWhat goes up, must come down. Ask any system administrato= r.=0AThere are 10 types of people in the world: Those who understand binary= , and those who don't.=0ATo understand recursion, we must first understand = recursion.=0A=0A----- Original Message ----=0AFrom: Rashmi Dixit <rashmid@g= mail.com>=0ATo: jso...@li...=0ASent: Wednesday, Nove= mber 29, 2006 1:53:17 AM=0ASubject: Re: [json-lib-user] Problem with conver= sion of BigDecimal to JSON text=0A=0AHi,=0A=0AWe have made changes to JSONU= tils.java and now BigDecimal is working.=0ACan you please review the change= s and let us know what you think?=0A=0ARegards=0A~Rashmi=0A=0A-----Original= Message-----=0AFrom: Rashmi Dixit [mailto:ra...@gm...] =0ASent: Wedn= esday, November 29, 2006 12:21 PM=0ATo: 'jso...@li...= t'=0ASubject: Problem with conversion of BigDecimal to JSON text=0A=0AHi,= =0A=0AWe are using JSON-lib 0.9 to convert our beans to JSON format before= =0Asending the response. Our bean uses many BigDecimal fields. We tried the= =0Afollowing:=0A=0AJSONObject.fromBean(new BigDecimal(10));=0A=0AThis throw= s the following exception:=0A=0ACaused by: java.lang.NoSuchMethodException:= Property 'scale' has no=0Agetter method=0Aat=0Aorg.apache.commons.beanutil= s.PropertyUtilsBean.getSimpleProperty(Propert=0AyUtilsBean.java:1127)=0Aat= =0Aorg.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(Propert= =0AyUtilsBean.java:686)=0Aat=0Aorg.apache.commons.beanutils.PropertyUtilsBe= an.getProperty(PropertyUtils=0ABean.java:715)=0Aat=0Aorg.apache.commons.bea= nutils.PropertyUtils.getProperty(PropertyUtils.jav=0Aa:290)=0Aat net.sf.jso= n.JSONObject.fromBean(JSONObject.java:161)=0A=0AThe apache commons searches= for getter setter methods for each member=0Avariable - which is not presen= t for this class.=0A=0AEven the fromObject method throws a similar exceptio= n. The JSON utils=0Afunction isNumber does not identify BigDecimal as a num= ber. This causes=0Aproblems here.=0A=0AWe have too many BigDecimal fields i= n our bean and so would rather not=0Amove to any other data type. Can you h= elp us here please? We are=0Acompletely stuck. =0A=0ARegards=0A~Rashmi=0A= =0A------------------------------------------------------------------------= -=0ATake Surveys. Earn Cash. Influence the Future of IT=0AJoin SourceForge.= net's Techsay panel and you'll get the chance to share your=0Aopinions on I= T & business topics through brief surveys - and earn cash=0Ahttp://www.tech= say.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV=0A________= _______________________________________=0Ajson-lib-user mailing list=0Ajson= -li...@li...=0Ahttps://lists.sourceforge.net/lists/listi= nfo/json-lib-user=0A=0A=0A=0A=0A=0A=0A=0A=09=0A=09=0A=09=09=0A_____________= ______________________________________________ =0ADo You Yahoo!? =0ALa mejo= r conexi=F3n a Internet y <b >2GB</b> extra a tu correo por $100 al mes. ht= tp://net.yahoo.com.mx =0A |
From: Rashmi D. <ra...@gm...> - 2006-11-29 07:53:26
|
Hi, We have made changes to JSONUtils.java and now BigDecimal is working. Can you please review the changes and let us know what you think? Regards ~Rashmi -----Original Message----- From: Rashmi Dixit [mailto:ra...@gm...] Sent: Wednesday, November 29, 2006 12:21 PM To: 'jso...@li...' Subject: Problem with conversion of BigDecimal to JSON text Hi, We are using JSON-lib 0.9 to convert our beans to JSON format before sending the response. Our bean uses many BigDecimal fields. We tried the following: JSONObject.fromBean(new BigDecimal(10)); This throws the following exception: Caused by: java.lang.NoSuchMethodException: Property 'scale' has no getter method at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(Propert yUtilsBean.java:1127) at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(Propert yUtilsBean.java:686) at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtils Bean.java:715) at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.jav a:290) at net.sf.json.JSONObject.fromBean(JSONObject.java:161) The apache commons searches for getter setter methods for each member variable - which is not present for this class. Even the fromObject method throws a similar exception. The JSON utils function isNumber does not identify BigDecimal as a number. This causes problems here. We have too many BigDecimal fields in our bean and so would rather not move to any other data type. Can you help us here please? We are completely stuck. Regards ~Rashmi |
From: Rashmi D. <ra...@gm...> - 2006-11-29 06:51:32
|
Hi, We are using JSON-lib 0.9 to convert our beans to JSON format before sending the response. Our bean uses many BigDecimal fields. We tried the following: JSONObject.fromBean(new BigDecimal(10)); This throws the following exception: Caused by: java.lang.NoSuchMethodException: Property 'scale' has no getter method at org.apache.commons.beanutils.PropertyUtilsBean.getSimpleProperty(Propert yUtilsBean.java:1127) at org.apache.commons.beanutils.PropertyUtilsBean.getNestedProperty(Propert yUtilsBean.java:686) at org.apache.commons.beanutils.PropertyUtilsBean.getProperty(PropertyUtils Bean.java:715) at org.apache.commons.beanutils.PropertyUtils.getProperty(PropertyUtils.jav a:290) at net.sf.json.JSONObject.fromBean(JSONObject.java:161) The apache commons searches for getter setter methods for each member variable - which is not present for this class. Even the fromObject method throws a similar exception. The JSON utils function isNumber does not identify BigDecimal as a number. This causes problems here. We have too many BigDecimal fields in our bean and so would rather not move to any other data type. Can you help us here please? We are completely stuck. Regards ~Rashmi |
From: Andres A. <aal...@ya...> - 2006-11-24 15:53:31
|
I have found the problem. This is a bug reported as http://sourceforge.net/= tracker/index.php?func=3Ddetail&aid=3D1592799&group_id=3D171425&atid=3D8579= 28=0Aand has already been fixed on the current development version (0.9-dev= ).=0AWith the example as is, the List will be filled with DynaBeans, if you= want Person objects instead=0Athe following code will work:=0A=0A Str= ing json =3D "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}";=0A JS= ONObject obj =3D new JSONObject( json );=0A Map classMap =3D new HashM= ap();=0A classMap.put( "data", Person.class );=0A MyBean bean =3D= (MyBean) JSONObject.toBean( obj, MyBean.class, classMap );=0A=0ACheers.=0A= =0A-------------------------------------------=0AIng. Andres Almiray Jaram= illo=0Ahttp://jroller.com/page/aalmiray=0A--=0AWhat goes up, must come down= . Ask any system administrator.=0AThere are 10 types of people in the world= : Those who understand binary, and those who don't.=0ATo understand recursi= on, we must first understand recursion.=0A=0A----- Original Message ----=0A= From: =EA=B9=80=EC=9D=91=EC=88=98 <sc...@gm...>=0ATo: Andres Almiray = <aal...@ya...>=0ASent: Thursday, November 23, 2006 10:30:36 PM=0ASubj= ect: Re: [json-lib-user] JSONObject.toBean() problem=0A=0AThank you for rep= ly~ :)=0A=0A=0A=0AI'm using 0.9 version, and JDK 1.5.=0A=0A=0A=0AHave you c= hecked the JSONObject.java source code? =0A=0A=0A=0AJSONObject.java 376 lin= e is=0A=0A> List list =3D JSONArray.toList( (JSONArray) value, beanClass, c= lassMap );=0A=0AThe 'beanClass' parameter is from JSONObject.toBean(...), a= nd it is 'MyBean.class'.=0A=0ABecause 'MyBean.class' doesn't have 'name' pr= operty, the exception was occured.=0A=0A=0A=0ASo, I think that the line sho= uld be like following,=0A=0A> List list =3D JSONArray.toList( (JSONArray) v= alue, null, classMap );=0A=0AThen, the list will have JSONArray instances, = and I will be able to convert it to Person obejct=0A=0Awith DynaBeanToBeanM= orpher.=0A=0A=0A=0AI have another idea. How about processing List like Map?= =0A=0AI think that if the type of a property is Map, the actual class is s= elected from 'classMap' parameter. (Is it right?)=0A=0ALike this, if the ty= pe of a property is List, the class can be selected from extra parameter, '= classList'. =0A=0AThe type of 'classList' may be java.lang.Map<String, Clas= s>. =0A=0AThen I don't have to use DynaBeanToBeanMorpher directly.=0A=0A=0A= =0AThanks for reading~ Good bye~=0A=0A=0A=0A2006/11/24, Andres Almiray <aal= mi...@ya...>:=0AI'm sorry for the confusion, but the last email is not = exactly true.=0AThe example describes the ability of JSON-lib to create Dyn= aBeans inside a list=0A=0Abecause it doesn't have any clues of what type of= objetcs it must create; then=0Aproceeds to exemplify the use of the DynaBe= anToBeanMorpher.=0A=0AI've tested the code you sent against release 0.9 and= it works without a problem,=0A=0Acan you tell me please which version are = you using ? =0A =0A-------------------------------------------=0AIng. Andre= s Almiray Jaramillo=0A=0Ahttp://jroller.com/page/aalmiray=0A--=0AWhat goes = up, must come down. Ask any system administrator.=0AThere are 10 types of p= eople in the world: Those who understand binary, and those who don't.=0ATo = understand=0A recursion, we must first understand recursion.=0A=0A=0A----- = Original Message ----=0AFrom: Andres Almiray <aal...@ya...>=0ATo: =EA= =B9=80=EC=9D=91=EC=88=98 <=0A...@ro...>; jso...@li...urce= forge.net=0ASent: Thursday, November 23, 2006 10:52:58 AM=0A=0ASubject: Re:= [json-lib-user] JSONObject.toBean() problem=0A=0AYou are correct, the docs= do not state that the toBean() method needs a =0A=0Ahint of what type of o= bjects are inside the collection, the correct code is=0A=0AString json =3D = "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}";=0AJSONObject obj =3D ne= w JSONObject(json);=0A=0AMap classMap =3D new HashMap();=0AclassMap.put( "d= ata",=0A Person.class );=0AMyBean bean =3D (MyBean) JSONObject.toBean( obj,= MyBean.class, classMap );=0A=0AThank you for spotting this problem :)=0A = =0A-------------------------------------------=0A=0AIng. Andres Almiray Jar= amillo=0Ahttp://jroller.com/page/aalmiray=0A--=0A=0AWhat goes up, must come= down. Ask any system administrator.=0AThere are 10 types of people in the = world: Those who understand binary, and those who don't.=0ATo understand re= cursion, we must first understand recursion.=0A=0A=0A----- Original Message= ----=0AFrom: =EA=B9=80=EC=9D=91=EC=88=98 <ki...@ro...>=0ATo: =0Ajson= -li...@li...=0ASent: Thursday, November 23, 2006 5:23:56= AM=0ASubject: [json-lib-user] JSONObject.toBean() problem=0A=0AHi all.=0A= =0AI've run the code in the 'Getting Started'=0A document.=0A=0A-----------= -------------------------------------------------=0Apublic static class MyB= ean{=0Aprivate List data;=0A=0Apublic List getData() {=0Areturn data;=0A}= =0A=0Apublic void setData(List data) {=0A=0Athis.data =3D data;=0A}=0A}=0A= =0Apublic static class Person{=0Aprivate String name;=0A=0Apublic String ge= tName() {=0Areturn=0A name;=0A}=0A=0Apublic void setName(String name) {=0At= his.name =3D name;=0A}=0A}=0A=0Apublic static void testTest() throws Except= ion=0A=0A{=0AString json =3D "{'data':[{'name':'Wallace'},{'name':'Grommit'= }]}";=0AJSONObject obj =3D new JSONObject(json);=0AMyBean bean =3D (MyBean)= JSONObject.toBean( obj, MyBean.class );=0A}=0A-----------------------------= -------------------------------=0A=0A=0AAnd following exception occured.=0A= =0A------------------------------------------------------------=0AException= in thread "main" net.sf.json.JSONException:=0Ajava.lang.NoSuchMethodExcept= ion: Unknown property 'name'=0A=0Aat net.sf.json.JSONObject.toBean(JSONObje= ct.java:439)=0Aat net.sf.json.JSONArray.toList(JSONArray.java:349)=0Aat net= .sf.json.JSONObject.toBean(JSONObject.java:376)=0Aat net.sf.json.JSONObject= .toBean(JSONObject.java=0A:325)=0Aat com.rolizen.test.jsonlib.JsonLibTest.t= estTest(JsonLibTest.java:96)=0Aat=0A com.rolizen.test.jsonlib.JsonLibTest.m= ain(JsonLibTest.java:21)=0ACaused by: java.lang.NoSuchMethodException: Unkn= own property 'name'=0Aat=0Aorg.apache.commons.beanutils.PropertyUtilsBean.s= etSimpleProperty(PropertyUtilsBean.java=0A:1741)=0Aat=0Aorg.apache.commons.= beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1648)= =0Aat=0Aorg.apache.commons.beanutils.PropertyUtilsBean.setProperty(Property= UtilsBean.java:1677)=0Aat=0Aorg.apache.commons.beanutils.PropertyUtils.setP= roperty=0A(PropertyUtils.java:559)=0Aat net.sf.json.JSONObject.setProperty(= JSONObject.java:484)=0Aat net.sf.json.JSONObject.toBean(JSONObject.java:408= )=0A... 5 more=0A----------------------------------------------------------= --=0A=0A=0AI think that at the 376 line in the JSONObject.java, invoking=0A= JSONArray.toList(...) method,=0Athe second parameter, 'beanClass' should no= t be passed.=0AInstead, null should be passed, I think.=0AThe intended clas= s of list item is 'Person', but=0A 'beanClass' is 'MyBean',=0Aso PropertyUt= ils cannot find 'name' property from 'beanClass'.=0A=0ADoesn't anyone have = this problem?=0A=0ASorry for poor english. :(=0A=0A=0A---------------------= ----------------------------------------------------=0A=0ATake Surveys. Ear= n Cash. Influence the Future of IT=0AJoin SourceForge.net's Techsay panel a= nd you'll get the chance to share your=0Aopinions on IT & business topics t= hrough brief surveys - and earn cash=0A=0Ahttp://www.techsay.com/default.ph= p?page=3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV=0A__________________________= _____________________=0Ajson-lib-user mailing list=0A=0Ajson-lib-user@lists= .sourceforge.net=0Ahttps://lists.sourceforge.net/lists/listinfo/json-lib-us= er=0A=0A=0A=0A=0A=0A=0A=09=09 =0ADo You Yahoo!? =0ALa mejor conexi=C3=B3n = a Internet y 2GB extra a tu correo por $100 al mes. http://net.yahoo.com.mx= =0A =0A--------------------------------------------------------------------= -----=0ATake Surveys. Earn Cash. Influence the Future of IT=0AJoin SourceFo= rge.net's Techsay panel and you'll get the chance to share your=0Aopinions = on IT & business topics through brief surveys - and earn cash=0A=0Ahttp://w= ww.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV=0A= =0A_______________________________________________=0Ajson-lib-user mailing = list=0Aj...@li...=0A=0Ahttps://lists.sourceforge.n= et/lists/listinfo/json-lib-user=0A=0A=0A=0A=0A=0A=0A=0A=0A=0A=09=09 =0ADo = You Yahoo!? =0ALa mejor conexi=C3=B3n a Internet y 2GB extra a tu correo po= r $100 al mes. http://net.yahoo.com.mx =0A=0A=0A=0A=0A---------------------= ----------------------------------------------------=0ATake Surveys. Earn C= ash. Influence the Future of IT=0AJoin SourceForge.net's Techsay panel and = you'll get the chance to share your=0Aopinions on IT & business topics thro= ugh brief surveys - and earn cash=0A=0Ahttp://www.techsay.com/default.php?p= age=3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV=0A=0A=0A_______________________= ________________________=0Ajson-lib-user mailing list=0Ajson-lib-user@lists= .sourceforge.net=0A=0Ahttps://lists.sourceforge.net/lists/listinfo/json-lib= -user=0A=0A=0A=0A=0A=0A=0A=0A=0A=0A=0A=0A=0A=09=0A=09=0A=09=09=0A__________= _________________________________________________ =0ADo You Yahoo!? =0ALa m= ejor conexi=C3=B3n a Internet y <b >2GB</b> extra a tu correo por $100 al m= es. http://net.yahoo.com.mx =0A |
From: Andres A. <aal...@ya...> - 2006-11-23 17:05:28
|
I'm sorry for the confusion, but the last email is not exactly true.=0AThe = example describes the ability of JSON-lib to create DynaBeans inside a list= =0Abecause it doesn't have any clues of what type of objetcs it must create= ; then=0Aproceeds to exemplify the use of the DynaBeanToBeanMorpher.=0A=0AI= 've tested the code you sent against release 0.9 and it works without a pro= blem,=0Acan you tell me please which version are you using ? =0A =0A-------= ------------------------------------=0AIng. Andres Almiray Jaramillo=0Ahttp= ://jroller.com/page/aalmiray=0A--=0AWhat goes up, must come down. Ask any s= ystem administrator.=0AThere are 10 types of people in the world: Those who= understand binary, and those who don't.=0ATo understand recursion, we must= first understand recursion.=0A=0A----- Original Message ----=0AFrom: Andre= s Almiray <aal...@ya...>=0ATo: =EA=B9=80=EC=9D=91=EC=88=98 <kimos@rol= izen.com>; jso...@li...=0ASent: Thursday, November 2= 3, 2006 10:52:58 AM=0ASubject: Re: [json-lib-user] JSONObject.toBean() prob= lem=0A=0AYou are correct, the docs do not state that the toBean() method ne= eds a =0Ahint of what type of objects are inside the collection, the correc= t code is=0A=0AString json =3D "{'data':[{'name':'Wallace'},{'name':'Grommi= t'}]}";=0AJSONObject obj =3D new JSONObject(json);=0AMap classMap =3D new H= ashMap();=0AclassMap.put( "data", Person.class );=0AMyBean bean =3D (MyBean= ) JSONObject.toBean( obj, MyBean.class, classMap );=0A=0AThank you for spot= ting this problem :)=0A =0A-------------------------------------------=0AIn= g. Andres Almiray Jaramillo=0Ahttp://jroller.com/page/aalmiray=0A--=0AWhat = goes up, must come down. Ask any system administrator.=0AThere are 10 types= of people in the world: Those who understand binary, and those who don't.= =0ATo understand recursion, we must first understand recursion.=0A=0A----- = Original Message ----=0AFrom: =EA=B9=80=EC=9D=91=EC=88=98 <ki...@ro...= m>=0ATo: jso...@li...=0ASent: Thursday, November 23,= 2006 5:23:56 AM=0ASubject: [json-lib-user] JSONObject.toBean() problem=0A= =0AHi all.=0A=0AI've run the code in the 'Getting Started' document.=0A=0A-= -----------------------------------------------------------=0Apublic static= class MyBean{=0Aprivate List data;=0A=0Apublic List getData() {=0Areturn d= ata;=0A}=0A=0Apublic void setData(List data) {=0Athis.data =3D data;=0A}=0A= }=0A=0Apublic static class Person{=0Aprivate String name;=0A=0Apublic Strin= g getName() {=0Areturn=0A name;=0A}=0A=0Apublic void setName(String name) {= =0Athis.name =3D name;=0A}=0A}=0A=0Apublic static void testTest() throws Ex= ception=0A{=0AString json =3D "{'data':[{'name':'Wallace'},{'name':'Grommit= '}]}";=0AJSONObject obj =3D new JSONObject(json);=0AMyBean bean =3D (MyBean= )JSONObject.toBean( obj, MyBean.class );=0A}=0A----------------------------= --------------------------------=0A=0AAnd following exception occured.=0A= =0A------------------------------------------------------------=0AException= in thread "main" net.sf.json.JSONException:=0Ajava.lang.NoSuchMethodExcept= ion: Unknown property 'name'=0Aat net.sf.json.JSONObject.toBean(JSONObject.= java:439)=0Aat net.sf.json.JSONArray.toList(JSONArray.java:349)=0Aat net.sf= .json.JSONObject.toBean(JSONObject.java:376)=0Aat net.sf.json.JSONObject.to= Bean(JSONObject.java:325)=0Aat com.rolizen.test.jsonlib.JsonLibTest.testTes= t(JsonLibTest.java:96)=0Aat=0A com.rolizen.test.jsonlib.JsonLibTest.main(Js= onLibTest.java:21)=0ACaused by: java.lang.NoSuchMethodException: Unknown pr= operty 'name'=0Aat=0Aorg.apache.commons.beanutils.PropertyUtilsBean.setSimp= leProperty(PropertyUtilsBean.java:1741)=0Aat=0Aorg.apache.commons.beanutils= .PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1648)=0Aat=0Aor= g.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.= java:1677)=0Aat=0Aorg.apache.commons.beanutils.PropertyUtils.setProperty(Pr= opertyUtils.java:559)=0Aat net.sf.json.JSONObject.setProperty(JSONObject.ja= va:484)=0Aat net.sf.json.JSONObject.toBean(JSONObject.java:408)=0A... 5 mor= e=0A------------------------------------------------------------=0A=0AI thi= nk that at the 376 line in the JSONObject.java, invoking=0AJSONArray.toList= (...) method,=0Athe second parameter, 'beanClass' should not be passed.=0AI= nstead, null should be passed, I think.=0AThe intended class of list item i= s 'Person', but=0A 'beanClass' is 'MyBean',=0Aso PropertyUtils cannot find = 'name' property from 'beanClass'.=0A=0ADoesn't anyone have this problem?=0A= =0ASorry for poor english. :(=0A=0A=0A-------------------------------------= ------------------------------------=0ATake Surveys. Earn Cash. Influence t= he Future of IT=0AJoin SourceForge.net's Techsay panel and you'll get the c= hance to share your=0Aopinions on IT & business topics through brief survey= s - and earn cash=0Ahttp://www.techsay.com/default.php?page=3Djoin.php&p=3D= sourceforge&CID=3DDEVDEV=0A_______________________________________________= =0Ajson-lib-user mailing list=0Aj...@li...=0Ahttps= ://lists.sourceforge.net/lists/listinfo/json-lib-user=0A=0A=0A=0A=0A=0A=09= =09 =0ADo You Yahoo!? =0ALa mejor conexi=C3=B3n a Internet y 2GB extra a t= u correo por $100 al mes. http://net.yahoo.com.mx =0A----------------------= ---------------------------------------------------=0ATake Surveys. Earn Ca= sh. Influence the Future of IT=0AJoin SourceForge.net's Techsay panel and y= ou'll get the chance to share your=0Aopinions on IT & business topics throu= gh brief surveys - and earn cash=0Ahttp://www.techsay.com/default.php?page= =3Djoin.php&p=3Dsourceforge&CID=3DDEVDEV=0A________________________________= _______________=0Ajson-lib-user mailing list=0Aj...@li...urcefo= rge.net=0Ahttps://lists.sourceforge.net/lists/listinfo/json-lib-user=0A=0A= =0A=0A=0A=0A=0A=0A=09=0A=09=0A=09=09=0A____________________________________= _______________________ =0ADo You Yahoo!? =0ALa mejor conexi=C3=B3n a Inter= net y <b >2GB</b> extra a tu correo por $100 al mes. http://net.yahoo.com.m= x =0A |
From: Andres A. <aal...@ya...> - 2006-11-23 16:53:07
|
You are correct, the docs do not state that the toBean() method needs a =0A= hint of what type of objects are inside the collection, the correct code is= =0A=0AString json =3D "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}";= =0AJSONObject obj =3D new JSONObject(json);=0AMap classMap =3D new HashMap(= );=0AclassMap.put( "data", Person.class );=0AMyBean bean =3D (MyBean) JSONO= bject.toBean( obj, MyBean.class, classMap );=0A=0AThank you for spotting th= is problem :)=0A =0A-------------------------------------------=0AIng. Andr= es Almiray Jaramillo=0Ahttp://jroller.com/page/aalmiray=0A--=0AWhat goes up= , must come down. Ask any system administrator.=0AThere are 10 types of peo= ple in the world: Those who understand binary, and those who don't.=0ATo un= derstand recursion, we must first understand recursion.=0A=0A----- Original= Message ----=0AFrom: =EA=B9=80=EC=9D=91=EC=88=98 <ki...@ro...>=0ATo:= jso...@li...=0ASent: Thursday, November 23, 2006 5:= 23:56 AM=0ASubject: [json-lib-user] JSONObject.toBean() problem=0A=0AHi all= .=0A=0AI've run the code in the 'Getting Started' document.=0A=0A----------= --------------------------------------------------=0Apublic static class My= Bean{=0Aprivate List data;=0A=0Apublic List getData() {=0Areturn data;=0A}= =0A=0Apublic void setData(List data) {=0Athis.data =3D data;=0A}=0A}=0A=0Ap= ublic static class Person{=0Aprivate String name;=0A=0Apublic String getNam= e() {=0Areturn name;=0A}=0A=0Apublic void setName(String name) {=0Athis.nam= e =3D name;=0A}=0A}=0A=0Apublic static void testTest() throws Exception=0A{= =0AString json =3D "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}";=0AJS= ONObject obj =3D new JSONObject(json);=0AMyBean bean =3D (MyBean)JSONObject= .toBean( obj, MyBean.class );=0A}=0A---------------------------------------= ---------------------=0A=0AAnd following exception occured.=0A=0A----------= --------------------------------------------------=0AException in thread "m= ain" net.sf.json.JSONException:=0Ajava.lang.NoSuchMethodException: Unknown = property 'name'=0Aat net.sf.json.JSONObject.toBean(JSONObject.java:439)=0Aa= t net.sf.json.JSONArray.toList(JSONArray.java:349)=0Aat net.sf.json.JSONObj= ect.toBean(JSONObject.java:376)=0Aat net.sf.json.JSONObject.toBean(JSONObje= ct.java:325)=0Aat com.rolizen.test.jsonlib.JsonLibTest.testTest(JsonLibTest= .java:96)=0Aat com.rolizen.test.jsonlib.JsonLibTest.main(JsonLibTest.java:2= 1)=0ACaused by: java.lang.NoSuchMethodException: Unknown property 'name'=0A= at=0Aorg.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(Prope= rtyUtilsBean.java:1741)=0Aat=0Aorg.apache.commons.beanutils.PropertyUtilsBe= an.setNestedProperty(PropertyUtilsBean.java:1648)=0Aat=0Aorg.apache.commons= .beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:1677)=0Aat= =0Aorg.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.jav= a:559)=0Aat net.sf.json.JSONObject.setProperty(JSONObject.java:484)=0Aat ne= t.sf.json.JSONObject.toBean(JSONObject.java:408)=0A... 5 more=0A-----------= -------------------------------------------------=0A=0AI think that at the = 376 line in the JSONObject.java, invoking=0AJSONArray.toList(...) method,= =0Athe second parameter, 'beanClass' should not be passed.=0AInstead, null = should be passed, I think.=0AThe intended class of list item is 'Person', b= ut 'beanClass' is 'MyBean',=0Aso PropertyUtils cannot find 'name' property = from 'beanClass'.=0A=0ADoesn't anyone have this problem?=0A=0ASorry for poo= r english. :(=0A=0A=0A-----------------------------------------------------= --------------------=0ATake Surveys. Earn Cash. Influence the Future of IT= =0AJoin SourceForge.net's Techsay panel and you'll get the chance to share = your=0Aopinions on IT & business topics through brief surveys - and earn ca= sh=0Ahttp://www.techsay.com/default.php?page=3Djoin.php&p=3Dsourceforge&CID= =3DDEVDEV=0A_______________________________________________=0Ajson-lib-user= mailing list=0Aj...@li...=0Ahttps://lists.sourcef= orge.net/lists/listinfo/json-lib-user=0A=0A=0A=0A=0A=0A=09=0A=09=0A=09=09= =0A___________________________________________________________ =0ADo You Ya= hoo!? =0ALa mejor conexi=C3=B3n a Internet y <b >2GB</b> extra a tu correo = por $100 al mes. http://net.yahoo.com.mx =0A |
From: <ki...@ro...> - 2006-11-23 11:24:03
|
Hi all. I've run the code in the 'Getting Started' document. ------------------------------------------------------------ public static class MyBean{ private List data; public List getData() { return data; } public void setData(List data) { this.data = data; } } public static class Person{ private String name; public String getName() { return name; } public void setName(String name) { this.name = name; } } public static void testTest() throws Exception { String json = "{'data':[{'name':'Wallace'},{'name':'Grommit'}]}"; JSONObject obj = new JSONObject(json); MyBean bean = (MyBean)JSONObject.toBean( obj, MyBean.class ); } ------------------------------------------------------------ And following exception occured. ------------------------------------------------------------ Exception in thread "main" net.sf.json.JSONException: java.lang.NoSuchMethodException: Unknown property 'name' at net.sf.json.JSONObject.toBean(JSONObject.java:439) at net.sf.json.JSONArray.toList(JSONArray.java:349) at net.sf.json.JSONObject.toBean(JSONObject.java:376) at net.sf.json.JSONObject.toBean(JSONObject.java:325) at com.rolizen.test.jsonlib.JsonLibTest.testTest(JsonLibTest.java:96) at com.rolizen.test.jsonlib.JsonLibTest.main(JsonLibTest.java:21) Caused by: java.lang.NoSuchMethodException: Unknown property 'name' at org.apache.commons.beanutils.PropertyUtilsBean.setSimpleProperty(PropertyUtilsBean.java:1741) at org.apache.commons.beanutils.PropertyUtilsBean.setNestedProperty(PropertyUtilsBean.java:1648) at org.apache.commons.beanutils.PropertyUtilsBean.setProperty(PropertyUtilsBean.java:1677) at org.apache.commons.beanutils.PropertyUtils.setProperty(PropertyUtils.java:559) at net.sf.json.JSONObject.setProperty(JSONObject.java:484) at net.sf.json.JSONObject.toBean(JSONObject.java:408) ... 5 more ------------------------------------------------------------ I think that at the 376 line in the JSONObject.java, invoking JSONArray.toList(...) method, the second parameter, 'beanClass' should not be passed. Instead, null should be passed, I think. The intended class of list item is 'Person', but 'beanClass' is 'MyBean', so PropertyUtils cannot find 'name' property from 'beanClass'. Doesn't anyone have this problem? Sorry for poor english. :( |
From: Andres A. <aal...@ya...> - 2006-10-12 20:06:20
|
Dear Open Source Community, I'm pleased to announce that json-lib version 0.9 has been released. JSON-lib is a java library for transforming beans, maps and XML to JSON and back again to beans and DynaBeans. It is based on the work by Douglas Crockford in http://www.json.org/java. Changelog: Additions: + Added FAQ and "Who is using it" sections. + Added new JSONSerializer utility class. + Added new interface JSON to identify a valid JSON type (JSONObject, JSONArray, JSONNull). + Added support for JSONString in builders and value setters. FR 1557286. Updates: + Removed JSONObject.append() as it was very similar to JSONObject.accumulate() + JSONObject and JSONarray will convert Byte/Short/Long to Integer, Float to Double when needed. + JSONArray.fromObject now allows creation of a single element array (all valid types). + Cleaned up the core API, moved mixed purpouse classes to net.sf.json.util + Updated front page and howto documentation. Fixes: 1564992 Multiple nested JSONException. 1553617 JSONObject.toBean() generates a ClassCastException. ___________________________________________________________ Do You Yahoo!? La mejor conexión a Internet y <b >2GB</b> extra a tu correo por $100 al mes. http://net.yahoo.com.mx |
From: Frederick P. <fpo...@po...> - 2006-09-07 18:49:47
|
No problem! The fix looks great, and prompt too. ;-) If only I could round-trip polymorphic object graphs from JSON, but alas this is a much more complicated problem! Fred -----Original Message----- From: Andres Almiray [mailto:aal...@ya...] Sent: Wednesday, September 06, 2006 2:24 PM To: Frederick Polgardy Subject: Re: [json-lib-user] Bug in toBean() for non-DynaBeans Hi Frederick, you are right, it is a bug. There shouldn't be an specific cast to Map in line 396. I'll add it to the bug database and get it fixed. Thanks for spotting it =] Cheers. |
From: Andres A. <aal...@ya...> - 2006-09-06 19:24:59
|
Hi Frederick, you are right, it is a bug. There shouldn't be an specific cast to Map in line 396. I'll add it to the bug database and get it fixed. Thanks for spotting it =] Cheers. --- Frederick Polgardy <fpo...@po...> escribió: > Greetings, > > There is a bug in the implementation of toBean() for > non-DynaBeans, > where for any non-primitive property, setting to > null always attempts a > (Map) cast (JSONObject.java, line 396), which fails > abruptly with a > ClassCastException. Changing && to || (line 392) > fixes this -- though > it doesn't technically set it to null, as it perhaps > should. But I > haven't investigated the utility enough to > understand the ramifications > of doing this. > > Fred > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support > web services, security? > Get stuff done quickly with pre-integrated > technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 > based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642> _______________________________________________ > json-lib-user mailing list > jso...@li... > https://lists.sourceforge.net/lists/listinfo/json-lib-user > ___________________________________________________________ Do You Yahoo!? La mejor conexión a Internet y <b >2GB</b> extra a tu correo por $100 al mes. http://net.yahoo.com.mx |