jq reformatting decimals in scientific notation — can this be avoided?

前端 未结 3 2089
轻奢々
轻奢々 2020-12-19 05:23

I found difference between json-data created by JavaScipt and via jq with bash (and other programming languages). With JavaScript I can create decimal numbers w

3条回答
  •  误落风尘
    2020-12-19 05:50

    You can't change jq's behavior -- at present date, relevant feature requests are still open -- but you can reformat your numbers after they've been retrieved. For example:

    json='{"decimal":0.00001}'
    decimal=$(jq '.decimal' <<<"$json")
    decimal_f=$(awk -v decimal="$decimal" 'BEGIN { printf("%f\n", decimal) }' 

提交回复
热议问题