Skip to content

Duplicate keys raise an error #1

@wjandrea

Description

@wjandrea

Example:

{"name": "Alice", "age": 30, "age": 30}

JSONLint says:

Invalid JSON!
Error: Duplicate key 'age'

However, duplicate keys are valid. ECMA-404 says:

The JSON syntax does not impose any restrictions on the strings used as names, does not require that name strings be unique, ...

So this data is valid.

That said, I agree that duplicate keys aren't good. They should raise a warning instead.

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