With `jq` how to transform:

```json
{
"key_0": {
"field_0": "value_0"
},
"key_1": {
"field_0": "value_1"
}
}
```

into:

```
key_0@value_0
key_1@value_1
```

?
Aug 25, 3:03pm

To transform the given JSON into the desired format using jq, you can use the following command:

bash
jq -r 'to_entries[] | "\(.key)@\(.value.field_0)"' input.json

Explanation:

  • to_entries[]: Converts the JSON object into an array of entries, where each entry has a key and a value.
  • "\(.key)@\(.value.field_0)": Constructs the desired string for each entry by combining the key and the field_0 value from the value object.
  • -r: Outputs the result as raw strings (without quotes).

Example:

If your input is saved in input.json, running the above command will produce:

text
key_0@value_0
key_1@value_1
Aug 25, 3:03pm

This is a shared conversation and may include unverified content that doesn't reflect Mistral AI's views. Login to resume chatting.

Vibe can make mistakes. Check answers. Learn more