JsonPointer incorrectly treats JSON strings as indexable sequences.
>>>fromjsonpointerimportJsonPointer>>>JsonPointer("/foo/0").resolve({"foo": "should-not-be-indexable"})
's'Per RFC 6901, reference tokens only apply to objects (member lookup) and arrays (index lookup). Applying /0 to a string should fail, but it returns the first character instead.
This bug has downstream implications as well:
>>>fromjsonpatchimportJsonPointer>>>patch= [{'op': 'test', 'path': '/foo/0', "value": "s"}]
>>>doc= {"foo": "should-not-be-indexable"}
>>>JsonPatch(patch).apply(doc)
{'foo': 'should-not-be-indexable'}>>>fromjsonpatchimportJsonPointer>>>doc= {"foo": "should-not-be-indexable"}
>>>patch= [{'op': 'copy', 'from': '/foo/0', "path": "/bar"}]
>>>JsonPatch(patch).apply(doc)
{'foo': 'should-not-be-indexable', 'bar': 's'}
JsonPointerincorrectly treats JSON strings as indexable sequences.Per RFC 6901, reference tokens only apply to objects (member lookup) and arrays (index lookup). Applying
/0to a string should fail, but it returns the first character instead.This bug has downstream implications as well: