flow-immutable-models icon indicating copy to clipboard operation
flow-immutable-models copied to clipboard

Provide `toJS` and `toJSON` functions

Open pbomb opened this issue 8 years ago • 3 comments

In order to support serialization, provide a toJS (and toJSON alias) function to convert the ImmutableModel into its modelType form.

pbomb avatar Dec 14 '16 21:12 pbomb

Why didn't you add toJSON? I think that toJSON would be a lot faster than toJS to encode the model as a string. Is that right?

Fi3 avatar Apr 10 '17 20:04 Fi3

Yeah, you're right. I'll put together a pull request to add toJSON as a shallow operation which will work better when using JSON.stringify

pbomb avatar Apr 10 '17 21:04 pbomb

I'm going to hold off on this until Immutable-JS 4.0.0 is released. The current version doesn't have correct flow types for the toJSON function.

pbomb avatar Apr 11 '17 03:04 pbomb