user1424739
user1424739

Reputation: 13735

Error in jq manual `jq '.[2:4]' <<< abcdefghi`?

The manual says

jq '.[2:4]'
   "abcdefghi"
=> "cd"

But a run of jq prints this:

$ jq '.[2:4]' <<< abcdefghi
parse error: Invalid numeric literal at line 2, column 0

Is the manual wrong? Or there is a bug in the program?

Upvotes: 1

Views: 46

Answers (1)

Benjamin W.
Benjamin W.

Reputation: 52431

abcdefghi is not a valid JSON string, but "abcdefghi" is:

$ jq '.[2:4]' <<< '"abcdefghi"'
"cd"

If you look at the jq play example linked from the manual, you'll see the double quoted input.

Upvotes: 4

Related Questions