We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
parent
1 parent f4281ba commit 27cdaadCopy full SHA for 27cdaad
jsonpath_rw/jsonpath.py
@@ -236,6 +236,27 @@ def __str__(self):
236
def __repr__(self):
237
return '%s(%r, %r)' % (self.__class__.__name__, self.left, self.right)
238
239
+class Parent(JSONPath):
240
+ """
241
+ JSONPath that matches the parent node of the current match.
242
+ Will crash if no such parent exists.
243
+ Available via named operator `parent`.
244
245
+
246
+ def find(self, datum):
247
+ datum = DatumInContext.wrap(datum)
248
+ return [datum.context]
249
250
+ def __eq__(self, other):
251
+ return isinstance(other, Parent)
252
253
+ def __str__(self):
254
+ return '`parent`'
255
256
+ def __repr__(self):
257
+ return 'Parent()'
258
259
260
class Where(JSONPath):
261
"""
262
JSONPath that first matches the left, and then
0 commit comments