jsonserializer

Serializing object that contains cyclic object value

寵の児 提交于 2019-11-26 06:33:42
I have an object (parse tree) that contains child nodes which are references to other nodes. I'd like to serialize this object, using JSON.stringify() , but I get : TypeError: cyclic object value because of the constructs I mentioned. How could I work around this? It does not matter to me whether these references to other nodes are represented or not in the serialized object. On the other hand, removing these properties from the object when they are being created seems tedious and I wouldn't want to make changes to the parser (narcissus). Use the second parameter of stringify , the replacer

Jackson enum Serializing and DeSerializer

点点圈 提交于 2019-11-26 03:03:18
问题 I\'m using JAVA 1.6 and Jackson 1.9.9 I\'ve got an enum public enum Event { FORGOT_PASSWORD(\"forgot password\"); private final String value; private Event(final String description) { this.value = description; } @JsonValue final String value() { return this.value; } } I\'ve added a @JsonValue, this seems to do the job it serializes the object into: {\"event\":\"forgot password\"} but when I try to deserialize I get a Caused by: org.codehaus.jackson.map.JsonMappingException: Can not construct

Serializing object that contains cyclic object value

笑着哭i 提交于 2019-11-26 00:53:10
问题 I have an object (parse tree) that contains child nodes which are references to other nodes. I\'d like to serialize this object, using JSON.stringify() , but I get TypeError: cyclic object value because of the constructs I mentioned. How could I work around this? It does not matter to me whether these references to other nodes are represented or not in the serialized object. On the other hand, removing these properties from the object when they are being created seems tedious and I wouldn\'t