Extracts a value from a nested set of dictionaries 'doc' based on a 'key' string. The key is expected to be a jsonpath_rw expression: http://jsonpath-rw.readthedocs.io/en/stable/ Returns the extracted value from the key specified (if found) Returns None if the key can not b
(doc, key)
| 62 | |
| 63 | |
| 64 | def _get_value_complex(doc, key): |
| 65 | """ |
| 66 | Extracts a value from a nested set of dictionaries 'doc' based on |
| 67 | a 'key' string. |
| 68 | The key is expected to be a jsonpath_rw expression: |
| 69 | http://jsonpath-rw.readthedocs.io/en/stable/ |
| 70 | |
| 71 | Returns the extracted value from the key specified (if found) |
| 72 | Returns None if the key can not be found |
| 73 | """ |
| 74 | jsonpath_expr = parse(key) |
| 75 | matches = jsonpath_expr.find(doc) |
| 76 | value = None if len(matches) < 1 else matches[0].value |
| 77 | return value |
| 78 | |
| 79 | |
| 80 | def get_value(doc, key): |