Re: [json-lib-user] Converting JSON strings to Java Maps
Brought to you by:
aalmiray
From: Andres A. <aal...@ya...> - 2007-05-29 15:59:59
|
Florian,=0AGenerics support is not in the roadmap (yet) but your example s= howed a potential flaw=0Ain the code that transforms a JSONObject into a be= an, the keys 'file1.java' and 'file2.java'=0Awill be transformed using the = configured JavaIdentifierTransformer and perhaps that is not=0Awhat you'll = want in sometimes, so I've added a new config setting to skip transformatio= n=0Aof keys that will be added to a map.=0A=0AKeep those questions coming!= =0A=0ACheers,=0AAndres=0A=0A-------------------------------------------=0Ah= ttp://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 understand recursion.= =0A=0A----- Mensaje original ----=0ADe: Florian Shkurti <florian.shkurti@gm= ail.com>=0APara: jso...@li...=0AEnviado: lunes, 28 d= e mayo, 2007 10:40:08=0AAsunto: [json-lib-user] Converting JSON strings to = Java Maps=0A=0AHi all,=0A=0AI have a question regarding the conversion of J= SON string=0Ainto Java objects. Please bare with me, as I have already =0Ar= ead json-lib's documentation, without being able to find =0Aanswers to all = of my questions. =0A=0A=0AConsider the following JSON string:=0A=0A{"commen= ts": {"file1.java" : [{ "pos_start": 34, "pos_end": 45}],=0A = "file2.java" : [{ "pos_start": 56, "pos_end": 78}] }}=0A=0A=0A= =0AI need to convert this string into a Java object. Ideally, I would=0Alik= e to obtain an object of the class=0A=0Apublic class MyBean{=0A =0A = private Map<String, List<Map<String, Integer>>> comments;=0A=0A=0A //= getters & setters=0A =0A}=0A=0AAny advice on how I could do that? = =0AIf not, can I avoid specifying a bean class with fields "file1.java"=0Aa= nd "file2.java" ? =0A=0A=0AThanks in advance,=0AFlorian=0A=0A=0A=0A=0A=0A--= -----------------------------------------------------------------------=0AT= his SF.net email is sponsored by DB2 Express=0ADownload DB2 Express C - the= FREE version of DB2 express and take=0Acontrol of your XML. No limits. Jus= t data. Click to get it now.=0Ahttp://sourceforge.net/powerbar/db2/=0A_____= __________________________________________=0Ajson-lib-user mailing list=0Aj= son...@li...=0Ahttps://lists.sourceforge.net/lists/li= stinfo/json-lib-user=0A=0A=0A=0A=0A=0A=0A=0A _________________________= _____________________ =0A=A1As=F3mbrate! Conoce el Beta de Correo Yahoo! qu= e incluye muchas herramientas que har=E1n tu vida m=E1s sencilla.=0Ahttp://= correo.yahoo.com.mx/ |