1

My test.json file contains the 2 keys:

{
 "id": "123",
 "name": "John"
}

And I want to achieve something like this:

{
 "id": "John"
}

where as you can see I change the value of the key id with the value of the key name. I'm guessing I have to use jq (I'm using Ubuntu) but I'm quite noob and I don't really now how to do it.

asked Dec 1, 2021 at 23:09

1 Answer 1

0

This should work:

jq '{id: .name}' input.json
answered May 14, 2022 at 14:14

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.