Jackson enum Serializing and DeSerializer

The serializer / deserializer solution pointed out by @xbakesx is an excellent one if you wish to completely decouple your enum class from its JSON representation. Alternatively, if you prefer a self-contained solution, an implementation based on @JsonCreator and @JsonValue annotations would be more convenient. So leveraging on the example by @Stanley the following is … Read more

Serializing object that contains cyclic object value

Use the second parameter of stringify, the replacer function, to exclude already serialized objects: var seen = []; JSON.stringify(obj, function(key, val) { if (val != null && typeof val == “object”) { if (seen.indexOf(val) >= 0) { return; } seen.push(val); } return val; }); http://jsfiddle.net/mH6cJ/38/ As correctly pointed out in other comments, this code removes … Read more