I am trying to increment a version field. Input is
{"version":1}
Output should be
{"v":2}
When I do
echo '{"version":1}'|jq '{"v":.version+1}'
I get
error: syntax error, unexpected '+', expecting '}'
While adding in string interpolation works
echo '{"version":1}'|jq '{"v":"\(.version+1)"}'
yields
{
"v":"2"
}
I need v to be of number type, though.
Try
echo '{"version":1}' | jq '{"v":(.version+1)}'
This seems to work on the playground of jq.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With