Skip to content

Feature request to (optionally) support "Python JSON" number extensions #1150

@ljwall

Description

@ljwall

It would be really great if Aeson was able to parse (and re-serialize) JSON generated with the Python json module, which has some extra (non-spec) features with regard to numbers:

import json
import math

print(
    json.dumps(
        {
            "foo": 99,
            "bar": math.nan,
            "baz": -math.inf
        }
    )
)

which yields

{"foo": 99, "bar": NaN, "baz": -Infinity}

I think NaN, Infinity and -Infinity are the only extra tokens that occur.

For me personally this comes up when working with JSON generated by data-scientists, where Python is the main language and these values seem to occur often.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions