Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSON to plain text using jq

Tags:

json

jq

Let's say i got the following json response:

{
  "author": "tomek",
  "title": "helloworld",
  "test": "sampletextonetwothree"
}

Is it possible to display something like this: (using jq)

author=tomek
title=helloworld
test=sampletextonetwothree
like image 983
kirovtome Avatar asked Sep 17 '25 03:09

kirovtome


2 Answers

jq 'to_entries[] | "\(.key)=\(.value)"'

should do it

like image 191
EdvardM Avatar answered Sep 20 '25 07:09

EdvardM


Another way to join the values is to use string concatenation:

jq -r 'to_entries[] | .key + "=" + .value'
like image 39
axiac Avatar answered Sep 20 '25 06:09

axiac