In a JSON object, given the string "0.0000086900" as the value of a key-value pair, if I do |tonumber on this, 8.69e-06 gets returned.
How can I ensure that only decimals are ever returned?
In the case above, this would be 0.0000086900
SOLUTION (based on Peak's code snippet below)
def to_decimal:
  def rpad(n): if (n > length) then . + ((n - length) * "0") else . end;
  def lpad(n): if (n > length) then ((n - length) * "0") + . else . end;
tostring
  | . as $s
  | [match( "(?<sgn>[+-]?)(?<left>[0-9]*)(?<p>\\.?)(?<right>[0-9]*)(?<e>[Ee]?)(?<exp>[+-]?[0-9]+)" )
      .captures[].string] as [$sgn, $left, $p, $right, $e, $exp]
  | if $e == "" then .
    else ($exp|tonumber) as $exp
    | ($left|length) as $len
    | if $exp < 0 then "0." + ($left | lpad(1 - $exp - $len)) + $right
      else ($left | rpad($exp - $len)) + "." + $right
      end
      | $sgn + .
    end;