-
Notifications
You must be signed in to change notification settings - Fork 31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to pass object to fromJSON #27
Comments
I think this could be considered a dupe of #25 - but this has a nice summary so i'm going to close that one instead. I think it is possible to allow decoding of an object as mentioned in #25 (comment) It's currently not possible to encode into an object due to cognitect/transit-js#23 |
What about a hacky interim solution that would check if input is an object and cast it to a string using This would abstract the issue at the There is no performance trade-off, because if you are not doing it – the user of the API will need to do it anyway. |
I don't think it'd be that difficult to create a If it does cross my path requirement-wise in the near future I'll probably tackle it myself. |
Sorry, I don't have time to make contributions to new OS projects. Have my hands full. |
No worries, I know the feeling! |
Use case scenario:
Server renders:
Client picks up
__PRELOADED_STATE__
, which is a valid JSON, therefore it is converted to an object. To use it, I need to cast it back to string, e.g.Alternatively, I can stringify the object twice on server: once using
transit-immutable-js
andsecond time using
JSON.stringify
, e.g.Preferably though,
transit-immutable-js
should be able to accept an object.The text was updated successfully, but these errors were encountered: