London | 26-SDC-Mar | Craig D'Silva | Sprint 2 | jq#393
Conversation
cjyuan
left a comment
There was a problem hiding this comment.
Solution works. I just have a few questions.
| # TODO: Write a command to output the name of the person. | ||
| # Your output should be exactly the string "Selma", but should not contain any quote characters. | ||
|
|
||
| cat person.json | jq -r ".name" No newline at end of file |
There was a problem hiding this comment.
Why not specify the input filename directly as:
jq -r .name person.json
?
There was a problem hiding this comment.
I thought cat with pipelines was required. Didn't know I could use it directly, just like grep.
| # TODO: Write a command to output the name of the person, then a comma, then their profession. | ||
| # Your output should be exactly the string "Selma, Software Engineer", but should not contain any quote characters. | ||
|
|
||
| cat person.json | jq -j '[.name, .profession] | join (", ")' No newline at end of file |
There was a problem hiding this comment.
Why use -j option on this particular command?
There was a problem hiding this comment.
I wanted to get a raw output to match the terminal format.
There was a problem hiding this comment.
-j option means "without adding a newline at the end".
What do you mean by "get a raw output to match the terminal format"?
| # Your output should be exactly the string "Selma", but should not contain any quote characters. | ||
|
|
||
| jq .name person.json No newline at end of file |
There was a problem hiding this comment.
Why remove the -r option? Now the requirement should not contain any quote characters is no longer satisfied.
Learners, PR Template
Self checklist
Changelist
I have completed the
jqexercises.