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"
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…