Skip to content

Prevent invalid JSON payload generation with Infinity #917

@guillett

Description

@guillett

Hi there!

I really enjoy OpenFisca, but I recently encountered an issue.

Here is what I did:

I run https://mes-aides.gouv.fr/ and receive user emails.

I tried to debug with self made tool (https://betagouv.github.io/openfisca-tracer) but the JSON payload could not be parsed.

I figured it was because of the Infinity presence in the payload.

Here is what I expected to happen:

Infinity should not be present as it is not a valid JSON token cf. StackOverflow.

Finite numbers are stringified as if by calling ToString(number). NaN and Infinity regardless of sign are represented as the String null.

Here is data (or links to it) that can help you reproduce this issue:

{
    "individus": {
        "_": {}
    },
    "familles": {
        "_": {
            "parents": [
                "_"
            ]
        }
    },
    "menages": {
        "_": {
            "niveau_de_vie": {
                "2019": null
            },
            "revenu_disponible": {
                "2019": 120
            },
            "unites_consommation": {
                "2019": 0
            },
            "personne_de_reference": [
                "_"
            ]
        }
    }
}

Context

I identify more as a:

  • Developer (I create tools that use the existing OpenFisca code).

Metadata

Metadata

Assignees

Labels

kind:fixBugs are defects and failure demand.

Type

No type

Projects

Status

Discussing / Discovering

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions