Signature def json_check(dict_or_list: Any, allow_datetimes: bool = False, xpath: str = '/') -> Iterator[Tuple[str, str, bool]]
Generator that yields xpath_expression, error_message, is_warning tuples as it encounters errors in the JSON object. The is_warning will be False for most things. This generator operates recursively to traverse the json object the current xpath value is passed in the recursive call
- Checks whether the value passed in is a
list or dict
- Allowed types within the json are:
int
str
float
list
dict
datetime, date, and time including timezone aware versions (if allow_datetime argument is True, and I'm not entirely certain about time)
- ensures that
dict keys are str and strings aren't empty
- If
dict has key that might be confused for a list index in an Xpath expression (i.e. {'100: 'foo'}) report this as a warning by setting the is_warning value to True`
Maybe define namedtuple or dataclass for the tuple being yielded
Signature
def json_check(dict_or_list: Any, allow_datetimes: bool = False, xpath: str = '/') -> Iterator[Tuple[str, str, bool]]Generator that yields xpath_expression, error_message, is_warning tuples as it encounters errors in the JSON object. The is_warning will be
Falsefor most things. This generator operates recursively to traverse the json object the current xpath value is passed in the recursive calllistordictintstrfloatlistdictdatetime,date, andtimeincluding timezone aware versions (ifallow_datetimeargument isTrue, and I'm not entirely certain abouttime)dictkeys arestrand strings aren't emptydicthas key that might be confused for a list index in an Xpath expression (i.e.{'100: 'foo'}) report this as a warning by setting the is_warning value toTrue`Maybe define
namedtupleordataclassfor the tuple being yielded