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

Ember 3.0 - Failed assertion when JSON.stringify -ing an Ember Object #16323

Closed
mani-mishra opened this issue Mar 5, 2018 · 2 comments
Closed

Comments

@mani-mishra
Copy link
Contributor

Upgrading to Ember 3.0 and using JSON.stringify, results in following failed assertion

Assertion Failed: You attempted to access `someValue.toJSON` (on `<(unknown mixin):ember2486>`), but `someValue` is a computed property.↵↵Due to certain internal implementation details of Ember,

I read the linked RFCs and discussion and I understand this is just a precautionary assertion, but this breaks JSON.stringify usage.

https://github.com/douglascrockford/JSON-js/blob/master/json2.js#L237-L238

screen shot 2018-03-05 at 6 48 09 pm

@rwjblue
Copy link
Member

rwjblue commented Mar 5, 2018

Thank you for reporting!

We need to add toJSON as an exception in this list:

property === 'toString' ||
property === 'valueOf' ||
property === 'inspect' ||
Symbol && property === Symbol.toPrimitive ||
Symbol && property === Symbol.toStringTag

@chancancode
Copy link
Member

Probably here too?

trap.toString = trap.valueOf = () => '[COMPUTED PROPERTY]';

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

3 participants