Skip to content

jdiff.extract_data

Extract data from JSON. Based on custom JMSPath implementation.

jdiff.extract_data.extract_data_from_json(data, path='*', exclude=None)

Return wanted data from outpdevice data based on the check path. See unit test for complete example.

Get the wanted values to be evaluated if JMESPath expression is defined, otherwise use the entire data if jmespath is not defined in check. This covers the "raw" diff type. Exclude data not desired to compare.

Notes

https://jmespath.org/ shows how JMESPath works.

Parameters:

Name Type Description Default
data Union[Mapping, List]

json data structure

required
path str

JMESPath to extract specific values

'*'
exclude Optional[List]

list of keys to exclude

None

Returns: Evaluated data, may be anything depending on JMESPath used.