-
-
Notifications
You must be signed in to change notification settings - Fork 83
Custom replacer context #4
Comments
you are right. It should be fixed now with tests included. Please check/test and close this ticket if it works as you expect. Thank you. |
P.S. … in your very specific example, you don't need to check if (value instanceof Date) return 'your thing'; That said, shared Dates objects across properties can be better packed via CircularJSON plus Date by default serialize into unserializable strings so eventually the problem would be in the |
done, both fixe with the right context. |
No, the provided value is already converted by the default stringifier. In this particular case, instead of date object, I'm getting string (in the format eg: "2013-10-01T16:15:58.181Z"). Anyway, already fixed my local version and tested. Seems to be working ok. Closed. |
The reviver had same issue. Grab the latest and you should be ok |
Hey, I'm using a custom replacer when stringifying objects such as dates and errors. After switching to circular-json, I noticed that my custom replacers weren't doing their job.
It seems the problem is here:
This doesn't pass the usual context for JSON.stringify - instead of the object being stringified, 'this' references the global JSON object. Since I was doing something like:
... my special converters weren't being called (a nasty silent fail). Suggested solution:
The text was updated successfully, but these errors were encountered: