Open natami opened 10 years ago
Yes, it does. You'll need to implement IJsonSerializable
in your Enum; and if you want to use ObjectUtils to parse the JSON back into a typed object, add a static fromNative(Object):Object
method .
I just fixed a bug with Enum.fromString
, so either be sure you have the latest version or parse the enum from the value instead.
Hi, Malachi!
Great - just what i was looking for ;)
What about circular references support?
Currently the workaround on the server side using Jackson (Json library) is to assign an id to each entity, see post: http://stackoverflow.com/questions/16478476/jackson-circular-reference
Could something like that be implemented in your serializer?
Regards!
On 05 Mar 2014, at 02:03, Malachi Griffie notifications@github.com wrote:
Yes, it does. You'll need to implement IJsonSerializable in your Enum; and if you want to use ObjectUtils to parse the JSON back into a typed object, add a static fromNative(Object):Object method .
I just fixed a bug with Enum.fromString, so either be sure you have the latest version or parse the enum from the value instead.
— Reply to this email directly or view it on GitHub.
There is unfortunately no support for circular references atm, so you'll probably just get a stack overflow.
I would recommend handling it in your model class since that is outside the scope of the serializer. (ie - I could just set any circular references to null; but the data will be lost since there is no way in JSON to represent a circular data structure.)
If you want to do it that way, just add a [Transient]
metadata tag to the properties which hold circular references and they won't be serialized.
Does the json serializer/deserializer support Enums?
eg. Java enums