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

Map and Set included in JSON output #57

Open
skeggse opened this issue Apr 1, 2020 · 1 comment
Open

Map and Set included in JSON output #57

skeggse opened this issue Apr 1, 2020 · 1 comment

Comments

@skeggse
Copy link

skeggse commented Apr 1, 2020

As I understand it, json tries to ensure that the output is JSON-compatible, at least in the types supported. It seems that Map and Set don't comply with this:

jsesc({ set: new Set([12]), map: new Map([['a', 'b']]) }, { json: true })
// => '{"set":new Set([12]),"map":new Map([["a","b"]])}'

JSON.parse encounters a SyntaxError when attempting to interpret this output, which seems undesirable.

@braco
Copy link

braco commented Mar 6, 2023

This just tripped me up too. If theres no array coercion, the "json" config name is not accurate

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

2 participants