json – Extractors for JSON data extracting.

class data_extractor.json.JSONExtractor(expr: str)

Bases: data_extractor.abc.SimpleExtractorBase

Use JSONPath expression for JSON data extracting.

Before extracting, should parse the JSON text into Python object.

Parameters

expr – JSONPath Expression.

extract(element: Any) → Any

Extract data from JSON data.

Parameters

element – Python object parsed from JSON text.

Returns

Data.

Raises

data_extractor.exceptions.ExprError – JSONPath Expression Error.

extract_first(element: Any, default: Any = sentinel) → Any

Extract the first data or subelement from extract method call result.

Parameters
Returns

Data or subelement.

Raises

data_extractor.exceptions.ExtractError – Thrown by extractor extracting wrong data.