Skip to content
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

Error: Cannot stringify arbitrary non-POJOs on Object that have a toJSON method #15

Closed
victor-perez opened this issue Oct 4, 2018 · 1 comment

Comments

@victor-perez
Copy link

If you have for example this code, I would expect that the toJSON method will be called of the object but instead it throws a non-POJOs error.

var devalue = require("devalue")
var { Map } = require('immutable');
console.log(devalue({
    test: new Map({a:1})
}))
@Rich-Harris
Copy link
Owner

The purpose of devalue is to create a string representation of objects in memory that has 100% fidelity — i.e., by evaluating the string, you get exactly the same structure as existing before serialization.

If it called toJSON methods, it would no longer provide that guarantee. It's therefore out of scope for this project, so I'll close this issue — thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants