Skip to content

JSON pointer handling of integer mapping key is undefined #477

@braingram

Description

@braingram

YAML unlike JSON allows integer keys.

>> asdf.AsdfFile({42: 'foo'})[42]
'foo'

The specification mentions support for JSON pointer style references.

>> af = asdf.AsdfFile({'foo': 42, 'ref': {'$ref': '#foo'}})
>> af.resolve_references()
>> af['ref']
42

However the following example fails:

>> af = asdf.AsdfFile({0: 'a', 'ref': {'$ref': '#0'}})
>> af.resolve_references()
ValueError: Unresolvable reference: '0'

Perhaps the implementation is wrong and the "0" string fragment should be converted to an integer. However with the following example that would mean it is impossible to reference 'b' (where currently the python asdf returns 'b').

>> af = asdf.AsdfFile({0: 'a', '0': 'b', 'ref': {'$ref': '#0'}})
>> af.resolve_references()
>> af['ref']
'b'

Perhaps this is additional evidence for the removal of JSON pointer: #444

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