bh_utils.json_funcs module

Common generic JSON functions. Require simplejson package.

For usage examples, see ./tests/test_json_funcs.py.

bh_utils.json_funcs.serialise(obj) str

JSON serialiser for objects not serialisable by default JSON code.

Reference:
Parameters:

obj – object to be serialisable. Currently recognising only datetime.

Returns:

a string representation of param obj.

Return type:

str.

  • datetime values are serialised into the Australian date format dd/mm/yyyy.

bh_utils.json_funcs.dumps(obj: dict | list) str

Serialise a dictionary or a list to a JSON string.

Date fields’ values are converted into the Australian date format dd/mm/yyyy.

Parameters:

obj – the dictionary or the list to be converted to JSON string.

Returns:

JSON string representation of param obj.

Return type:

str.