Y
Hacker News
new
|
ask
|
show
|
jobs
by
zimbatm
4832 days ago
I'm not familiar with Backbone but isn't `model.toJSON()` unnecessarily removing useful data types (like Date) that aren't available in JSON ?
1 comments
papercrane
4832 days ago
You're probably thinking of `JSON.stringify()`. `model.toJSON()` just returns a clone of the models attributes object.
link
zimbatm
4832 days ago
So `model.toJSON()` isn't supposed to return a JSON-compatible data structure ?
link
papercrane
4832 days ago
It's supposed to return an object that is suitable for turning into JSON, but it won't convert any of items members. JSON.stringify relies on the toJSON functions of the members to serialize themselves.
link