Categories
How to add an element inside an array in json using jq?
using the jq tool, you need to add an element to the array, for example: from {"a":1,"b":[1,2]} you need to get {"a":1,"b":[1,2,3]}
Answer the question
In order to leave comments, you need to log in
пока получился такой вариант:
$ echo '{"a":1,"b":[1,2]}' | jq -c '. + {b:(.b + [3])}' {"a":1,"b":[1,2,3]}
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question