
The jsonutils.dumps() function returns bytes on Python 2 and Unicode oon Python 3. In some cases, we always want bytes. For example, a HTTP body must be bytes. This function avoids an condition call to .encode() depending on the type or on the Python version. For example: body = jsonutils.dumps(data) if isinstance(body, six.text_type): body = body.encode('utf-8') can be replaced with: body = jsonutils.dump_as_bytes(data) Change-Id: Ib9d8f1309982762b54d8a91b1f24f64d0ae6723a
oslo.serialization
The oslo.serialization library provides support for representing objects in transmittable and storable formats, such as JSON and MessagePack.
- Free software: Apache license
- Documentation: http://docs.openstack.org/developer/oslo.serialization
- Source: http://git.openstack.org/cgit/openstack/oslo.serialization
- Bugs: http://bugs.launchpad.net/oslo.serialization
Description
Languages
Python
100%