woob.tools.json
¶
- mini_jsonpath(node, path)[source]¶
Evaluates a dot separated path against JSON data. Path can contains star wilcards. Always returns a generator.
Relates to https://goessner.net/articles/JsonPath/ but in a really basic and simpler form.
>>> list(mini_jsonpath({"x": 95, "y": 77, "z": 68}, 'y')) [77] >>> list(mini_jsonpath({"x": {"y": {"z": "nested"}}}, 'x.y.z')) ['nested'] >>> list(mini_jsonpath('{"data": [{"x": "foo", "y": 13}, {"x": "bar", "y": 42}, {"x": "baz", "y": 128}]}', 'data.*.y')) [13, 42, 128]