Victor Stinner 92f2111b26 Add jsonutils.dump_as_bytes() function for py3
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
2015-09-23 15:23:43 +02:00
2015-06-27 16:24:23 -04:00
2015-09-17 12:16:12 +00:00

oslo.serialization

Latest Version

Downloads

The oslo.serialization library provides support for representing objects in transmittable and storable formats, such as JSON and MessagePack.

Description
OpenStack library for serialization
Readme 3.2 MiB
Languages
Python 100%