3434
3535""" Identify specific nodes in a JSON document (RFC 6901) """
3636
37+ try :
38+ from collections .abc import Mapping , Sequence
39+ except ImportError :
40+ from collections import Mapping , Sequence
41+
3742# Will be parsed by setup.py to determine package metadata
3843__author__ = 'Stefan Kögl <stefan@skoegl.net>'
3944__version__ = '1.4'
@@ -191,10 +196,10 @@ def set(self, doc, value, inplace=True):
191196 def get_part (self , doc , part ):
192197 """ Returns the next step in the correct type """
193198
194- if isinstance (doc , dict ):
199+ if isinstance (doc , Mapping ):
195200 return part
196201
197- elif isinstance (doc , list ):
202+ elif isinstance (doc , Sequence ):
198203
199204 if part == '-' :
200205 return part
@@ -220,14 +225,14 @@ def walk(self, doc, part):
220225
221226 assert (type (doc ) in (dict , list ) or hasattr (doc , '__getitem__' )), "invalid document type %s" % (type (doc ),)
222227
223- if isinstance (doc , dict ):
228+ if isinstance (doc , Mapping ):
224229 try :
225230 return doc [part ]
226231
227232 except KeyError :
228233 raise JsonPointerException ("member '%s' not found in %s" % (part , doc ))
229234
230- elif isinstance (doc , list ):
235+ elif isinstance (doc , Sequence ):
231236
232237 if part == '-' :
233238 return EndOfList (doc )
0 commit comments