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.
1 parent 003a0b7 commit a77121eCopy full SHA for a77121e
jsonpath_ng/ext/filter.py
@@ -48,6 +48,17 @@ def find(self, datum):
48
len(list(filter(lambda x: x.find(datum.value[i]),
49
self.expressions))))]
50
51
+ def update(self, data, val):
52
+ if type(data) is list:
53
+ for index, item in enumerate(data):
54
+ shouldUpdate = len(self.expressions) == len(list(filter(lambda x: x.find(item), self.expressions)))
55
+ if shouldUpdate:
56
+ if hasattr(val, '__call__'):
57
+ val.__call__(data[index], data, index)
58
+ else:
59
+ data[index] = val
60
+ return data
61
+
62
def __repr__(self):
63
return '%s(%r)' % (self.__class__.__name__, self.expressions)
64
0 commit comments