Skip to content

JSON parsing issue with UINT64 / INT64 enum values #842

Description

@lilleyse

The following schema is unsafe when parsed by the built-in JSON parser in JavaScript.

{
  "enums": {
    "model": {
      "valueType": "UINT64",
      "values": [
        {
          "value": 9007199254740991, // parsed as 9007199254740991
          "name": "Floor"
        },
        {
          "value": 9007199254740992, // parsed as 9007199254740992
          "name": "Wall"
        },
        {
          "value": 9007199254740993, // xxx - parsed as 9007199254740992, not exactly representable as JavaScript Number
          "name": "Door"
        }
      ]
    }
  }
}

Should "value" be a string instead?

{
  "enums": {
    "model": {
      "valueType": "UINT64",
      "values": [
        {
          "value": "9007199254740991",
          "name": "Floor"
        },
        {
          "value": "9007199254740992",
          "name": "Wall"
        },
        {
          "value": "9007199254740993",
          "name": "Door"
        }
      ]
    }
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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