here.platform.utils package#

HERE Platform, utilities package

class here.platform.utils.JsonDictDocument(json_dict: Dict[str, Any])[source]#

Bases: object

A JSON document used in APIs loaded into a Dict. Used as base class.

Calling code can inspect the document via to_dict. Subclasses typically add also read-only properties via the @property annotation to expose some of the most significant fields in a developer-friendly, typed, controlled way.

Constructors provided by subclasses help the creation of complex JSON documents from significant fields, providing names, types and sensible defaults.

Subclasses can also be created and initialized using from_dict.

property fields: List#

Returns all available fields in the service

Returns:

List of fields

classmethod from_dict(json_dict: Dict[str, Any])[source]#

Create a subclass of JsonDictDocument and initialize its content using a JSON structure in a Dict already available.

This method is used by the SDK to load JSON API responses into a document.

Use this on subclasses of JsonDictDocument but not directly on JsonDictDocument. Initialization of subclasses is skipped. Subclasses should not define any field or behavior (apart from calling the parent __init__) in their constructor as these won’t be defined when the subclass is created with this class method.

Parameters:

json_dict – the JSON document loaded into a Dict

Returns:

A new object of the class specified, initialized using json_dict

get_field(field_name: str) Any[source]#

Get value of a field in service

Parameters:

field_name – name of the field to be read

Returns:

value of the field

has_field(field_name: str) bool[source]#

Checks whether the field is present

Parameters:

field_name – name of the field to be checked

Returns:

True if field is present else False

property json: Dict[str, Any]#

The JSON representation of the document in a python dictionary

to_dict() Dict[str, Any][source]#

Expose the document as python dictionary.

Returns:

the unchanged document as python dictionary

Submodules#