I have a JSON value:
{
"ssh_key": {
"id": 123
}
}
How i can print id object by jq utility as string? Object value must be (with double quotas):
{
"id": "123"
}
I use jq '.ssh_key | {id}
command for print without double quotes now.
Thanks.
CodePudding user response:
Use the tostring
(or the @text
) builtin to convert into a string:
jq '.ssh_key | .id |= tostring'
{
"id": "123"
}