All Projects → axiros → nested_encode

axiros / nested_encode

Licence: other
Converts unicode objects, in a nested structure (eg. json.loads), into utf-8 encoded bytes.

Programming Languages

python
139335 projects - #7 most used programming language
c
50402 projects - #5 most used programming language

nested_encode

Converts unicode objects, in a nested structure (eg. json.loads), into utf-8 encoded bytes. For example:

# Before
{u'a': [{'b': [(1, 2, [u'\xd6sterreich'])]}]}

# After
{'a': [{'b': [(1, 2, ['\xc3\x96sterreich'])]}]}

Note: dictionaries are copied, lists and tuples are changed inplace.

Performance overhead: around 10%.

Usage

import simplejson
from nested_encode import encode_nested


def loads(data):
    return encode_nested(simplejson.loads(data))

Install

pip install git+https://github.com/axiros/nested_encode.git
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].