[json-lib-user] Problems with .toJava
Brought to you by:
aalmiray
|
From: Kiril <kir...@gm...> - 2008-05-10 06:54:37
|
Hi all,
I'm newbie to json-lib.
I want to use it to serialize a class with a List<Class>, containing number
of subclasses.
While toJSON works fine, passing back the same string to toJava works only
partially - the root class is generated Ok, but the children, in the List
are MorphDynaBean's.
Here is the code:
JSONUtils.getMorpherRegistry().registerMorpher(new
EnumMorpher(GroupComparison.class));
JSONUtils.getMorpherRegistry().registerMorpher(new
EnumMorpher(NextGroupComparison.class));
JSONUtils.getMorpherRegistry().registerMorpher(new
EnumMorpher(FieldComparison.class));
JSONObject jsonObject = new JSONObject();
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.setRootClass( Filter.class );
jsonConfig.setEnclosedType(List.class);
jsonObject = (JSONObject)JSONSerializer.toJSON(jsonString);
Filter filter = (Filter)JSONSerializer.toJava(jsonObject,
jsonConfig);
The Filter class contains List of Group classes, but these are generated as
a MorphDynaBean...
Thanks in advance for any help!
Kiril.
|