Quantcast
Channel: Active questions tagged jq - Stack Overflow
Viewing all articles
Browse latest Browse all 657

How to convert a string to an integer in a JSON file using jq?

$
0
0

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: (.value.booking_service_code)}' companies.json

Now, the (.key) is parsed as a string, yet I want companyId to be a number.

My result currently looks like this:

{"companyId": "1337","companyTitle": "Some company title","companyCode": "oxo"}

yet it should be like:

{"companyId": 1337,"companyTitle": "Some company title","companyCode": "oxo"}

Viewing all articles
Browse latest Browse all 657

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>