Hello! Thank you for this library. I discovered it today and both the lib and its documentation are a real treat. I used it to transform a deep json payload in a mitmproxy script, and it was perfect for that.
I however encountered a bug in the Item lens in a use case I had. It was similar to this example: a traversal over values of existing "foo" entries in a list of dictionaries. I figured I would contribute a test case and a fix.
In current version 1.1.0, it crashes with KeyError: 'foo' in the setter method of ItemLens.
Note that this is not the same traversal as lens.Each().Get("foo").Filter(bool), whose use instead results in [[{'foo': None}, {'foo': 'hello world'}] (which, incidentally, had me a bit confused at first).
Hello! Thank you for this library. I discovered it today and both the lib and its documentation are a real treat. I used it to transform a deep json payload in a mitmproxy script, and it was perfect for that.
I however encountered a bug in the Item lens in a use case I had. It was similar to this example: a traversal over values of existing "foo" entries in a list of dictionaries. I figured I would contribute a test case and a fix.
With this PR, this now returns true:
In current version 1.1.0, it crashes with
KeyError: 'foo'
in thesetter
method ofItemLens
.Note that this is not the same traversal as
lens.Each().Get("foo").Filter(bool)
, whose use instead results in[[{'foo': None}, {'foo': 'hello world'}]
(which, incidentally, had me a bit confused at first).