You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If you stringify an object it will not JSON stringify it:
s = require('javascript-stringify')
console.log(JSON.stringify({hi:'howdy'}))
console.log(s.stringify({hi:'howdy'}))
outputs:
{"hi":"howdy"}
{hi:'howdy'}
This means it is not a real stringifyer. it is a make human readable stringifyer. If you try to run JSON.parse(s.stringify({hi:'howdy'})) it will throw an error Unexpected token h in JSON at position 0
The text was updated successfully, but these errors were encountered:
This is not a JSON stringifier, this is a JavaScript stringifier. As the README notes, the intent is to generate valid JavaScript not JSON. Otherwise you could just use JSON.stringify, as you have noted.
If you stringify an object it will not JSON stringify it:
outputs:
This means it is not a real stringifyer. it is a make human readable stringifyer. If you try to run
JSON.parse(s.stringify({hi:'howdy'}))
it will throw an errorUnexpected token h in JSON at position 0
The text was updated successfully, but these errors were encountered: