I use jq to transform a complex json object into a tinier one. My query is:
jq \'to_entries[]| {companyId: (.key), companyTitle: (.value.title), companyCode:
I was trying to turn my string (that converts to a float) to an integer. I was looking for a 'toint' function, one doesn't exist.
jq --arg str "1.435" -n '$str|tonumber'
1.435
I threw a floor in there to make sure the number that was created was an integer:
jq --arg str "1.435" -n '$str|tonumber|floor'
1
This also properly converts the OP original data as well. If you want to guarantee your result is an integer you will need to floor it.