Thread: Re: [json-lib-user] Json and POJO Conversion
Brought to you by:
aalmiray
From: Andres A. <aal...@ya...> - 2007-07-05 17:53:26
|
Hi Petr,=0AI think you can find what you're looking for in net.sf.json.JSON= Serializer=0AIt will let you serialize a Java bean, map, array, collection = into JSON and back, =0Ayou may specify a target class when converting back = to Java or leave it blank,=0Athe result will be a DynaBean compatible with = jakarta's bean-utils.=0A =0ACheers,=0AAndres=0A=0A=0A----------------------= ---------------------=0Ahttp://jroller.com/page/aalmiray=0Ahttp://www.linke= din.com/in/aalmiray=0A--=0AWhat goes up, must come down. Ask any system adm= inistrator.=0AThere are 10 types of people in the world: Those who understa= nd binary, and those who don't.=0ATo understand recursion, we must firs= t understand recursion.=0A=0A----- Mensaje original ----=0ADe: Petr V. <gre= atm...@ya...>=0APara: jso...@li...=0AEnviado: = jueves, 5 de julio, 2007 12:46:43=0AAsunto: [json-lib-user] Json and POJO C= onversion=0A=0AHi,=0A=0AI have some POJO Objects and I need to convert them= into JSON Objects and vice versa. Is there Any API that provides this func= tionality or I have to do manually conversion.=0A=0AI saw some sample code = here =0A=0Ahttp://dev2dev.bea.com/pub/a/2007/02/introduction-json.html=0A= =0Awhere they are converting address book entry (POJO) into JSON object man= ually and then converting it into String. The next question is that can I m= ake JSON object using that String again ?? Is there any efficient way to co= nvert pojo into json or vice versa, please let me know.=0A=0AThanks,=0A=0AP= etr V.=0A =0A =0ASick sense of humor? Visit Yahoo! TV's =0AComedy with= an Edge to see what's on, when. =0A=0A=0A---------------------------------= ----------------------------------------=0AThis SF.net email is sponsored b= y DB2 Express=0ADownload DB2 Express C - the FREE version of DB2 express an= d take=0Acontrol of your XML. No limits. Just data. Click to get it now.=0A= http://sourceforge.net/powerbar/db2/=0A____________________________________= ___________=0Ajson-lib-user mailing list=0Aj...@li...urceforge.= 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 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-07-05 18:30:56
|
Your welcome Pter, in fact when transforming from JSON to Java not only do = arrays will be=0Ahandled but arrays of primitives, muldimensional arrays an= d collections.=0AJust call JSONSerializer.toJava() after properly configuri= ng targetClass and classMap (if needed)=0A=0AYou may find more info at the = project site.=0A=0ACheers,=0AAndres=0A =0A---------------------------------= ----------=0Ahttp://jroller.com/page/aalmiray=0Ahttp://www.linkedin.com/in/= 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 understan= d recursion.=0A=0A----- Mensaje original ----=0ADe: Petr V. <greatman787@ya= hoo.com>=0APara: Andres Almiray <aal...@ya...>; json-lib-user@lists.s= ourceforge.net=0AEnviado: jueves, 5 de julio, 2007 13:13:42=0AAsunto: Re: [= json-lib-user] Json and POJO Conversion=0A=0AThanks Andres, your reply was = very useful.=0A =0A I also found http://www.json.org/javadoc/org/json/JSONO= bject.html#JSONObject(java.lang.Object,%20java.lang.String[])=0A =0A but th= en I have to pass the attributes name of POJO object. =0A=0AI will try the = toJSON( ) method of JSONSerializer, would it be able to convert the collect= ions in POJO like arrays , maps, lists etc??=0A=0AThanks a lot once again, = =0A=0APetr=0A=0AAndres Almiray <aal...@ya...> wrote: Hi Petr,=0AI thi= nk you can find what you're looking for in net.sf.json.JSONSerializer=0AIt = will let you serialize a Java bean, map, array, collection into JSON and ba= ck, =0Ayou may specify a target class when converting back to Java or leave= it=0A blank,=0Athe result will be a DynaBean compatible with jakarta's bea= n-utils.=0A =0ACheers,=0AAndres=0A=0A=0A-----------------------------------= --------=0Ahttp://jroller.com/page/aalmiray=0Ahttp://www.linkedin.com/in/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 understa= nd recursion.=0A=0A----- Mensaje original ----=0ADe: Petr V. <greatman787@y= ahoo.com>=0APara: jso...@li...=0AEnviado: jueves, 5 = de julio, 2007 12:46:43=0AAsunto:=0A [json-lib-user] Json and POJO Conversi= on=0A=0AHi,=0A=0AI have some POJO Objects and I need to convert them into J= SON Objects and vice versa. Is there Any API that provides this functionali= ty or I have to do manually conversion.=0A=0AI saw some sample code here = =0A=0Ahttp://dev2dev.bea.com/pub/a/2007/02/introduction-json.html=0A=0Awher= e they are converting address book entry (POJO) into JSON object manually a= nd then converting it into String. The next question is that can I make JSO= N object using that String again ?? Is there any efficient way to convert = pojo into json or vice versa, please let me know.=0A=0AThanks,=0A=0APetr V.= =0A =0ASick sense of humor? Visit Yahoo! TV's Comedy with an Edge t= o see what's on, when.=0A ----------------------------------------------= ---------------------------=0AThis SF.net email is sponsored by DB2 Express= =0ADownload DB2 Express C - the FREE version of DB2 express and take=0Acont= rol of your XML. No limits. Just data. Click to get it now.=0Ahttp://source= forge.net/powerbar/db2/=0A_______________________________________________= =0Ajson-lib-user mailing list=0Aj...@li...=0Ahttps= ://lists.sourceforge.net/lists/listinfo/json-lib-user=0A=0A=0A=0A=0A=0A=0A = Do You Yahoo!? La mejor conexi=F3n a Internet y 2GB extra a tu correo= por $100 al mes. http://net.yahoo.com.mx =0A =0A =0ABe a better Hear= tthrob. Get better relationship answers from someone who knows.=0AYahoo! An= swers - Check it out. =0A=0A=0A=0A=0A=0A=0A=09=0A=09=0A=09=09=0A___________= ________________________________________________ =0ADo You Yahoo!? =0ALa me= jor conexi=F3n a Internet y <b >2GB</b> extra a tu correo por $100 al mes. = http://net.yahoo.com.mx =0A |
From: Petr V. <gre...@ya...> - 2007-07-05 18:13:50
|
Thanks Andres, your reply was very useful. I also found http://www.json.org/javadoc/org/json/JSONObject.html#JSONObject(java.lang.Object,%20java.lang.String[]) but then I have to pass the attributes name of POJO object. I will try the toJSON( ) method of JSONSerializer, would it be able to convert the collections in POJO like arrays , maps, lists etc?? Thanks a lot once again, Petr Andres Almiray <aal...@ya...> wrote: Hi Petr, I think you can find what you're looking for in net.sf.json.JSONSerializer It will let you serialize a Java bean, map, array, collection into JSON and back, you may specify a target class when converting back to Java or leave it blank, the result will be a DynaBean compatible with jakarta's bean-utils. Cheers, Andres ------------------------------------------- http://jroller.com/page/aalmiray http://www.linkedin.com/in/aalmiray -- What goes up, must come down. Ask any system administrator. There are 10 types of people in the world: Those who understand binary, and those who don't. To understand recursion, we must first understand recursion. ----- Mensaje original ---- De: Petr V. <gre...@ya...> Para: jso...@li... Enviado: jueves, 5 de julio, 2007 12:46:43 Asunto: [json-lib-user] Json and POJO Conversion Hi, I have some POJO Objects and I need to convert them into JSON Objects and vice versa. Is there Any API that provides this functionality or I have to do manually conversion. I saw some sample code here http://dev2dev.bea.com/pub/a/2007/02/introduction-json.html where they are converting address book entry (POJO) into JSON object manually and then converting it into String. The next question is that can I make JSON object using that String again ?? Is there any efficient way to convert pojo into json or vice versa, please let me know. Thanks, Petr V. --------------------------------- Sick sense of humor? Visit Yahoo! TV's Comedy with an Edge to see what's on, when. ------------------------------------------------------------------------- This SF.net email is sponsored by DB2 Express Download DB2 Express C - the FREE version of DB2 express and take control of your XML. No limits. Just data. Click to get it now. http://sourceforge.net/powerbar/db2/ _______________________________________________ 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 2GB extra a tu correo por $100 al mes. http://net.yahoo.com.mx --------------------------------- Be a better Heartthrob. Get better relationship answers from someone who knows. Yahoo! Answers - Check it out. |