The openstack_dashboard.openstack.common.jsonutils ModuleΒΆ

JSON related utilities.

This module provides a few things:

1) A handy function for getting an object down to something that can be JSON serialized. See to_primitive().

2) Wrappers around loads() and dumps(). The dumps() wrapper will automatically use to_primitive() for you if needed.

3) This sets up anyjson to use the loads() and dumps() wrappers if anyjson is available.

openstack_dashboard.openstack.common.jsonutils.dumps(value, default=<function to_primitive at 0x4da7410>, **kwargs)[source]
openstack_dashboard.openstack.common.jsonutils.load(s)[source]
openstack_dashboard.openstack.common.jsonutils.loads(s)[source]
openstack_dashboard.openstack.common.jsonutils.to_primitive(value, convert_instances=False, convert_datetime=True, level=0, max_depth=3)[source]

Convert a complex object into primitives.

Handy for JSON serialization. We can optionally handle instances, but since this is a recursive function, we could have cyclical data structures.

To handle cyclical data structures we could track the actual objects visited in a set, but not all objects are hashable. Instead we just track the depth of the object inspections and don’t go too deep.

Therefore, convert_instances=True is lossy ... be aware.

Previous topic

The openstack_dashboard.openstack.common.policy Module

Next topic

The openstack_dashboard.openstack.common.gettextutils Module

This Page