Friday, September 25, 2009

flexjson deserialization of pojos ???

FLEXJSON includes code for deserialization in version 1.7

Hero hero = new JSONDeserializer().use( null, Hero.class ).deserialize( jsonHarvey ); 

doesn't appear to work with a POJO (might work with a bean, not interested in that). serialization works with POJOs, and the deserialization docs don't mention that it doesn't ... the code runs, but the fields aren't set correctly, ie they're left with the values set by the no-arg constructor

anyone have any luck deserializing a POJO ?

here's a guy using deserialization, but he doesn't say whether he's got a POJO or a Bean ...

[SOLVED] ok - just tried google-gson, and it deserializes POJOs ... only a very simple example so far, but it works. guess i'll switch to gson



1 comment:

punit said...

Yes flexjson is giving problem at the time of deserialiation, particulary when you want a particular instance type for a particular field. And has different bugs in different versions. I also switched to google gson and it is deserialing json without any pain.