sqlalchemyseed.json#

Module Contents#

class sqlalchemyseed.json.JsonWalker(json: list | dict = None)#

JsonWalker class

property current_key: int | str#

Returns the key of the current json

property json#

Returns current json

property json_is_dict#

Returns true if current json is dict

property json_is_list#

Returns true if current json is list

backward()#

Revert current json to its parent. Returns reverted current json

exec_func_iter(func: Callable)#

Executes function when iterating

find_from_current(keys: List[int | str])#

Find item from current json that correlates list of keys

find_from_root(keys: List[int | str])#

Find item from the root json that correlates list of keys

forward(keys: List[int | str])#

Move and replace current json forward. Returns current json.

iter_as_dict_items()#

Iterates current as dict. Yields key and value.

Raises TypeError if current json is not dict

iter_as_list()#

Iterates current as list. Yields index and value.

Raises TypeError if current json is not list

keys()#

Returns list of keys either str or int

reset(root=None)#

Resets to initial state. If root argument is supplied, self.root will be replaced.

sqlalchemyseed.json.sort_json(json: list | dict, reverse=False)#

Sort json function