-
Notifications
You must be signed in to change notification settings - Fork 41
Description
I am trying to index a list of dict object via resolve_pointer() and came across the following error. This happens with both version 1.1 and 1.7. The output is as below:
bliang@latite:~/lumberjack/python-json-pointer$ python
Python 2.6.6 (r266:84292, Jun 18 2012, 09:57:52)
[GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
from jsonpointer import resolve_pointer
ranges = {'items': [{'start': 7, 'end': 7}, {'start': 23, 'end': 23}, {'start': 37, 'end': 37}, {'start': 107, 'end': 107}, {'start': 179, 'end': 179}, {'start': 513, 'end': 514}, {'start': 1494, 'end': 1494}, {'start': 1718, 'end': 1720}, {'start': 2000, 'end': 2003}, {'start': 2427, 'end': 2427}, {'start': 2598, 'end': 2598}, {'start': 2727, 'end': 2727}, {'start': 3389, 'end': 3389}, {'start': 5060, 'end': 5060}, {'start': 5631, 'end': 5631}, {'start': 5900, 'end': 5903}, {'start': 6000, 'end': 6000}], 'label': u'Interactive'}
resolve_pointer(ranges, '/items/-')
EndOfList([{'start': 7, 'end': 7}, {'start': 23, 'end': 23}, {'start': 37, 'end': 37}, {'start': 107, 'end': 107}, {'start': 179, 'end': 179}, {'start': 513, 'end': 514}, {'start': 1494, 'end': 1494}, {'start': 1718, 'end': 1720}, {'start': 2000, 'end': 2003}, {'start': 2427, 'end': 2427}, {'start': 2598, 'end': 2598}, {'start': 2727, 'end': 2727}, {'start': 3389, 'end': 3389}, {'start': 5060, 'end': 5060}, {'start': 5631, 'end': 5631}, {'start': 5900, 'end': 5903}, {'start': 6000, 'end': 6000}])
resolve_pointer(ranges, '/items/-/start')
Traceback (most recent call last):
File "", line 1, in
File "jsonpointer.py", line 111, in resolve_pointer
return pointer.resolve(doc, default)
File "jsonpointer.py", line 168, in resolve
doc = self.walk(doc, part)
File "jsonpointer.py", line 224, in walk
part = self.get_part(doc, part)
File "jsonpointer.py", line 218, in get_part
"must be dict/list or support getitem" % type(doc))
jsonpointer.JsonPointerException: Document '<class 'jsonpointer.EndOfList'>' does not support indexing, must be dict/list or support getitem