1

I am just trying with this basic line, but I am not getting, here is the command.

echo {“x”:1} | jq '[ . ]'

It is showing the error as follows.

parse error: Invalid numeric literal at line 1, column 9

The expected output is :

[{"x":1}]
2
  • 1
    - is invalid quoting char Commented Oct 31, 2017 at 9:52
  • I have changed , even though it is not working Commented Oct 31, 2017 at 9:54

1 Answer 1

3

and are invalid quoting chars, the valid quoting char is ".
The second moment is that the echo command arguments should be enclosed in single or double quotes (in conformity with argument content) to present a literal string:

echo '{"x":1}{"y":1}' | jq -s '.'
[
  {
    "x": 1
  },
  {
    "y": 1
  }
]
Sign up to request clarification or add additional context in comments.

2 Comments

echo '{"x":1}{"y":1}' | jq [.] output is :::: [ { "x": 1 } ] [ { "y": 1 } ] If I want output like [ {...} {...} ] , what can I do?
@NagaVenkateshGavini, use -s option: echo '{"x":1}{"y":1}' | jq -s '.'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.