This is a quick and dirty example:
$ jq -r '.[] | "--metadata \"key\": \"\(.key)\", \"value\": \"\(.value)\""' so8247.json | awk 'ORS=" "'
--metadata "key": "Name", "value": "John" --metadata "key": "City", "value": "New York" --metadata "key": "Country", "value": "USA"
(EDIT: see below for how to do this without awk)
The .[] bit just loops through the elements of the array; map(x) is equivalent to [.[] | x] so this is almost the same thing, just without throwing the results into an array that we don't want.
The rest of it just creates the string you're interested in. You can use \(x) to drop more JQ into the middle of the string. The output without '-r' and the awk would look like this:
$ jq '.[] | "--metadata \"key\": \"\(.key)\", \"value\": \"\(.value)\""' so8247.json
"--metadata \"key\": \"Name\", \"value\": \"John\""
"--metadata \"key\": \"City\", \"value\": \"New York\""
"--metadata \"key\": \"Country\", \"value\": \"USA\""
The '-r' gets rid of all of the extra quoting:
$ jq -r '.[] | "--metadata \"key\": \"\(.key)\", \"value\": \"\(.value)\""' so8247.json
--metadata "key": "Name", "value": "John"
--metadata "key": "City", "value": "New York"
--metadata "key": "Country", "value": "USA"
And the awk combines it into one line.
Using map gives you nearly the same thing, wrapped in an array:
$ jq -r 'map("--metadata \"key\": \"\(.key)\", \"value\": \"\(.value)\"")' so8247.json
[
"--metadata \"key\": \"Name\", \"value\": \"John\"",
"--metadata \"key\": \"City\", \"value\": \"New York\"",
"--metadata \"key\": \"Country\", \"value\": \"USA\""
]
Which is pretty easy to strip off:
$ jq -r 'map("--metadata \"key\": \"\(.key)\", \"value\": \"\(.value)\"") | .[]' so8247.json
--metadata "key": "Name", "value": "John"
--metadata "key": "City", "value": "New York"
--metadata "key": "Country", "value": "USA"
Through that through awk and you're done:
$ jq -r 'map("--metadata \"key\": \"\(.key)\", \"value\": \"\(.value)\"") | .[]' so8247.json | awk 'ORS=" "'
--metadata "key": "Name", "value": "John" --metadata "key": "City", "value": "New York" --metadata "key": "Country", "value": "USA"
NOTE: Obviously I don't know how to do the awk bit in pure JQ; hopefully someone will show us how to do that, if it's possible.
EDIT: I just saw @oguz ismail's comment; using map and join gets rid of the need for awk:
$ jq -r 'map("--metadata \"key\": \"\(.key)\", \"value\": \"\(.value)\"") | join(" ")' so8247.json
--metadata "key": "Name", "value": "John" --metadata "key": "City", "value": "New York" --metadata "key": "Country", "value": "USA"
EDIT: Using Charles Duffy's suggestion of using from the comment of using '-j' to eliminate the map, join, and awk:
$ jq -j '.[] | "--metadata \"key\": \"\(.key)\", \"value\": \"\(.value)\""' so8247.json
--metadata "key": "Name", "value": "John"--metadata "key": "City", "value": "New York"--metadata "key": "Country", "value": "USA"