[Python] Disable scientific notation in python json.dumps output

Discussão em 'Python' iniciado por Stack, Março 19, 2025.

  1. Stack

    Stack Membro Participativo

    json.dumps outputs small float or decimal values using scientific notation, which is unacceptable to the json-rpc application this output is sent to.

    >>> import json
    >>> json.dumps({"x": 0.0000001})
    '{"x": 1e-07}'


    I want this output instead:

    '{"x": 0.0000001}'


    It would be ideal to avoid introducing additional dependencies.

    Continue reading...

Compartilhe esta Página