Re: [json-lib-user] JSONObject.toBean() in a Object with an Array Property
Brought to you by:
aalmiray
From: Pedro P. <ped...@we...> - 2010-11-18 15:45:49
|
Being that java is case sensitive, and JSON is case sensitive, I'd risk saying that capitalization IS indeed your problem On Nov 18, 2010, at 3:16 PM, Everton Agner wrote: > Hi! > > I need to convert this JSON string > > {"Name":"Apple","Expiry":"\/Date(1230429600000-0200)\/","Price":3.99,"Sizes":["Small","Medium","Large"]} > > To this JavaBean > > public class Product > { > private String name; > private Date expiry; > private BigDecimal price; > private String[] sizes; > } > > With this code > > JSONObject json = JSONObject.fromObject(jsonText); > > Product p = (Product) JSONObject.toBean(json, Product.class); > > > And I'm getting this exception: > > Exception in thread "main" net.sf.json.JSONException: java.lang.NoSuchMethodException: Unknown property 'Sizes' on class 'class Product' > > > I don't think it's because os case sensitivity (it's an Object created on C#, that's why the properties are Pascal Case). > > What do i need to do to make this work? I searched for it and got nothing... > > > Thanks! > > _______________________ > Everton Agner Ramos > ------------------------------------------------------------------------------ > Beautiful is writing same markup. Internet Explorer 9 supports > standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. > Spend less time writing and rewriting code and more time creating great > experiences on the web. Be a part of the beta today > http://p.sf.net/sfu/msIE9-sfdev2dev_______________________________________________ > json-lib-user mailing list > jso...@li... > https://lists.sourceforge.net/lists/listinfo/json-lib-user |