Utils
This module implements the CloudCIX API JSON Encodes and Decoders, along with other utilities to improve the quality of life for anyone using the CloudCIX library.
- class cloudcix.utils.JSONEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)
JSONEncoder that can encode date/time/timedelta, decimal and other python objects into JSON.
Inspired by Django Rest Framework
- default(obj)
Converts the passed object into its JSON representation, usually by converting them into a string.
- Parameters:
obj (object) – The object to be converted into JSON
- class cloudcix.utils.JSONDecoder(*args, **kwargs)
JSONDecoder that can decode date/time/timedelta, decimal and other strings into python objects.
Inspired by Django Rest Framework.
- __init__(*args, **kwargs)
Create an instance of the Decoder.
See
json.JSONDecoder
for the constructor parameters.
- parse(obj)
Parse a JSON value into its python equivalent.
If the value is an iterable, this method will be called recursively on every item contained within the value.
- Parameters:
obj (Any) – The JSON object to be decoded into Python.