enums are not working as expected

78 views
Skip to first unread message

CB

unread,
Oct 22, 2012, 6:57:11 AM10/22/12
to jso...@googlegroups.com
hi,

I've been having hard times with json-io and enums.

First - you must have a custom deserialization method - otherwise the JsonReader will fail. Why is that??
Second, If I use duplicate values of a certain enum, the custom deserializer will fail. I don't know how to fix that - can anyone help??

Attached is a simple example (TestJsonEnums.java) that demonstrate all the issues related to enums.

Can anyone take a look and help me?

Thanks!
CB


TestJsonEnums.java

John

unread,
Oct 26, 2012, 5:11:36 PM10/26/12
to jso...@googlegroups.com
Enum support has been added in the upcoming version.  This new version (should be released in November 2012) adds improved support for customizing output and input, and most importantly, supports reading JSON into a JVM that does not have the classes that match the JSON read.  

This is done by reading the input into a Map of Maps representation, and retaining the appropriate information.  These Maps (JsonObject's) can be manipulated by having values changed, fields added, etc.  When this Map of Maps representation is passed to the JsonWriter, it write's the content back out, using the same IDs and format as the original input.

I am also looking at the appropriate changes to allow json-io to be used as a substitute for Jackson.  Furthermore, there is an upcoming JsonCommandServlet that will give you a servlet that will receive JSON 'commands', process those, and return JSON output back to the browser (calling Javascript).

This version will support full graph serialization (cycle support) unlink the JSON2.stringify().  The November release is just of the JsonReader/JsonWriter.   Likely in December / Jan timeframe the JsonCommandServlet will be released.

Regards,
John

Stav

unread,
Nov 29, 2012, 7:45:46 PM11/29/12
to jso...@googlegroups.com
Hi John,

The enum support sounds great. I don't see any updates in the trunk code though. Is this enhancement available yet or do we need to await the next release (ie code updates are not committed until released)?

Cheers,
Stav

John DeRegnaucourt

unread,
Nov 30, 2012, 12:32:57 AM11/30/12
to jso...@googlegroups.com
Enum support should be available sometime between Dec 1st and Dec 7th.

Best regards,
John

John

unread,
Jan 13, 2013, 12:02:22 PM1/13/13
to jso...@googlegroups.com
Enum support was added in the latest 2.0 release that is available for download.


On Friday, November 30, 2012 12:32:57 AM UTC-5, John wrote:
Enum support should be available sometime between Dec 1st and Dec 7th.

Best regards,
John
Reply all
Reply to author
Forward
0 new messages