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

Make jsesc --object accept non-JSON-formatted data as well #9

Open
mathiasbynens opened this issue Aug 1, 2013 · 0 comments
Open

Comments

@mathiasbynens
Copy link
Owner

$ jsesc --object '{"foo":42}' 
{'foo':42}

$ jsesc --object "{'foo':42}"
Unexpected token '

Error: failed to escape.
If you think this is a bug in jsesc, please report it:
https://github.com/mathiasbynens/jsesc/issues/new

Stack trace using jsesc@0.4.1:

SyntaxError: Unexpected token '
    at Object.parse (native)
    at /usr/local/share/npm/lib/node_modules/jsesc/bin/jsesc:85:20
    at Array.forEach (native)
    at main (/usr/local/share/npm/lib/node_modules/jsesc/bin/jsesc:49:11)
    at /usr/local/share/npm/lib/node_modules/jsesc/bin/jsesc:110:3
    at Object.<anonymous> (/usr/local/share/npm/lib/node_modules/jsesc/bin/jsesc:133:2)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)

This is currently by design, since we use JSON.parse(). But maybe we could use something like @espadrine’s localeval instead?

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

1 participant