Skip to content

implement json_check function #11

Description

@jocassid

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions