deathfish
deathfish

Reputation: 41

JQ number output format

For an input below:

abc@abc:~$ curl https://bittrex.com/api/v1.1/public/getticker?market=btc-doge | jq ".result.Ask"

Output to jq:

{"success":true,"message":"","result":"Bid":0.00000034,"Ask":0.00000035,"Last":0.00000035}}

Output from jq:

3.5e-07

how in JQ switch number output format 3.5e-07 to 0.00000035 ?

Upvotes: 4

Views: 3467

Answers (1)

Jack Bracken
Jack Bracken

Reputation: 1283

It's not ideal, but you can use printf to format a number in scientific notation as a decimal.

$ printf '%.8f' $(curl -s https://bittrex.com/api/v1.1/public/getticker?market=btc-doge | jq ".result.Ask")
0.00000035

The .8 in the printf command is specifying 8 places of precision. You can specify .10 and you will get:

0.0000003500

Or specify lower precision .4 and lose data.

0.0000

Upvotes: 4

Related Questions