[json-lib-user] Problem converting json property to Set
Brought to you by:
aalmiray
|
From: Alexander C. <a.s...@gm...> - 2010-10-25 09:04:34
|
Hello.
I have a problem to convert from json to Java.
I have json:
{"data":{"characteristics":[{"name":"qeqwe","description":"qweqwe","characte
risticType":"BOOLEAN"}],"id":12}}
And Java bean:
public class ResourceSpecModel { private Long id; private
Set<ResourceSpecCharModel> characteristics; public Long getId() { return
id; } public void setId(Long id) { this.id = id; } public
Set<ResourceSpecCharModel> getCharacteristics() { return characteristics; }
public void setCharacteristics(Set<ResourceSpecCharModel> characteristics) {
this.characteristics = characteristics; } }
When I try to convert json to java using JSONSerializer.toJava(object,
jsonConfig) I get wrong result.
Object is JSONObject it contains JSONArray of characteristics.
I expect that characteristics will be converted to
Set<ResourceSpecCharModel> but have a Set of MorphDynaBean instead of
ResourceSpecCharModel:
[net.sf.ezmorph.bean.MorphDynaBean@3dcecfaa[{description=qweqwe, name=qeqwe,
characteristicType=BOOLEAN}]]
RootClass in jsonConfig setted to ResourceSpecModel. ResourceSpecCharModel
has all getters and setters.
What I'm doing wrong?
|