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

Call out in instructions when quotation marks are needed #6

Open
dsiegal opened this issue Jan 16, 2020 · 1 comment
Open

Call out in instructions when quotation marks are needed #6

dsiegal opened this issue Jan 16, 2020 · 1 comment

Comments

@dsiegal
Copy link

dsiegal commented Jan 16, 2020

The instructions for the "objects" lesson always show what followsjq enclosed in single quotes, e.g. the '[.foo]' in the first example:

$ echo '{"foo": { "bar": "a value" }}' \
      | jq '[.foo]'

In the interactive tutorial, following suit with single quotes succeeds in the first two exercises:

Given:    'product' (type "data?" to view)
Challenge: Create a new object containing just the "name" field

> '{name}'

--------------------------------

Given:    'product' (type "data?" to view)
Challenge: Construct an array containing the product's name

> '[.name]'

But fails in the 3rd:

--------------------------------

Given:    'product' (type "data?" to view)
Challenge: Extend the product with { color: "red" }

> '{ price, name, "color":"red" }'

Command failed: jq ''{ price, name, "color":"red" }'' /usr/local/lib/node_modules/jq-tutorial/data/product.json
jq: error: syntax error, unexpected $end (Unix shell quoting issues?) at <top-level>, line 1:
{
jq: 1 compile error

I had no idea what I was doing wrong. Finally looked at the solution the in code and realized I was expected to omit the single quotes:

> { price, name, "color":"red" }

Suggest calling out in the instructions to omit them (or making it work with single quotes).

I'd be happy to update the instructions if you agree. Thanks!

@rjz
Copy link
Owner

rjz commented Jan 17, 2020

Fair—thanks, @dsiegal!

Suggest calling out in the instructions to omit them (or making it work with single quotes).

I'd be happy to update the instructions if you agree. Thanks!

Given the command-line experience updating the script to ignore (optional) single quotes seems like a good change to make... but at the very least, a "don't worry about escaping strings" note would save folks from tripping up on this in the future. +1 from me!

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