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

Parse error when key name starts with a number #51

Open
Tomaskom-cz opened this issue Apr 25, 2016 · 1 comment
Open

Parse error when key name starts with a number #51

Tomaskom-cz opened this issue Apr 25, 2016 · 1 comment

Comments

@Tomaskom-cz
Copy link

jsawk fails to extract a value for a key when it's name starts with a number.
(or name of any key in the chain)

This works fine:

echo '{"val1":"v1","2val":"v2"}' | ./jsawk "return this.val1"
v1

This fails:

echo '{"val1":"v1","2val":"v2"}' | ./jsawk "return this.2val"
jsawk: script parse error: 'return this.2val'
@guido4000
Copy link

You can escape the key with brackets:

echo '{"val1":"v1","2val":"v2"}' | jsawk "return this['2val']"

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