kolodny/jsan

Support for Immutable.js

Closed this issue · 2 comments

As reported in zalmoxisus/redux-devtools-extension#67, "deep" serialization breaks immutable data.

So, jsan.stringify(obj) will return for ... "todoList": immutable.List()

{"monitorState":{},"actionsById":{"0":{"type":"PERFORM_ACTION","action":{"type":"@@INIT"},"timestamp":1456848558040}},"nextActionId":1,"stagedActionIds":[0],"skippedActionIds":[],"currentStateIndex":0,"computedStates":
[{"state":{"todos":{"activeFilter":"all",

"todoList":[]

}}}]
}

While jsan.stringify(obj, null, null, true) returns

{"monitorState":{},"actionsById":{"0":{"type":"PERFORM_ACTION","action":{"type":"@@INIT"},"timestamp":1456848558040}},"nextActionId":1,"stagedActionIds":[0],"skippedActionIds":[],"committedState":{"$jsan":"u"},"currentStateIndex":0,"computedStates":[{"state":{"todos":{"activeFilter":"all",

"todoList":{"size":0,"_origin":0,"_capacity":0,"_level":5,"_root":{"$jsan":"u"},"_tail":{"$jsan":"u"},"__ownerID":{"$jsan":"u"},"__hash":{"$jsan":"u"},"__altered":false}}},"error":{"$jsan":"u"}}

]}

Is there a way to support Immutable.js also on "deep" serialization or we should use only jsan.stringify(obj) in this case? If not, I'm going to just let the users to choose which type of serialization to use.

I just pushed 3.1.1 which should fix this.