Skip to content
This repository was archived by the owner on Mar 5, 2022. It is now read-only.
This repository was archived by the owner on Mar 5, 2022. It is now read-only.

toJSON should return an object, not a string #9

Description

@bartaz

JSON.stringify uses value returned by toJSON and serializes it to string, so it should be an object.
Currenty Model objects are double-serialized when using JSON.stringify on them.

Please refer to:

 When an object value is found, if the object contains a toJSON
 method, its toJSON method will be called and the result will be
 stringified. A toJSON method does not serialize: it returns the
 value represented by the name/value pair that should be serialized,
 or undefined if nothing should be serialized. 

https://github.com/douglascrockford/JSON-js/blob/master/json.js#L75-81

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions