diff options
author | 2015-08-26 18:16:09 +0300 | |
---|---|---|
committer | 2015-08-26 18:16:09 +0300 | |
commit | f8ac9d14a989c8cf1535e16165551dfa370b0b74 (patch) | |
tree | 43e396eb5d096ad74ec02afeccf8995a4d241a0f /external_libs/python/zmq/utils/jsonapi.py | |
parent | cdcc62972d42f009f55e6aeb2ca5c60c3acd75eb (diff) | |
parent | 53f0e28d7f30c7175cbb15884c309613593859d8 (diff) |
Merge branch 'master' into dan_stateless
Diffstat (limited to 'external_libs/python/zmq/utils/jsonapi.py')
-rw-r--r-- | external_libs/python/zmq/utils/jsonapi.py | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/external_libs/python/zmq/utils/jsonapi.py b/external_libs/python/zmq/utils/jsonapi.py deleted file mode 100644 index 865ca6d5..00000000 --- a/external_libs/python/zmq/utils/jsonapi.py +++ /dev/null @@ -1,59 +0,0 @@ -"""Priority based json library imports. - -Always serializes to bytes instead of unicode for zeromq compatibility -on Python 2 and 3. - -Use ``jsonapi.loads()`` and ``jsonapi.dumps()`` for guaranteed symmetry. - -Priority: ``simplejson`` > ``jsonlib2`` > stdlib ``json`` - -``jsonapi.loads/dumps`` provide kwarg-compatibility with stdlib json. - -``jsonapi.jsonmod`` will be the module of the actual underlying implementation. -""" - -# Copyright (C) PyZMQ Developers -# Distributed under the terms of the Modified BSD License. - -from zmq.utils.strtypes import bytes, unicode - -jsonmod = None - -priority = ['simplejson', 'jsonlib2', 'json'] -for mod in priority: - try: - jsonmod = __import__(mod) - except ImportError: - pass - else: - break - -def dumps(o, **kwargs): - """Serialize object to JSON bytes (utf-8). - - See jsonapi.jsonmod.dumps for details on kwargs. - """ - - if 'separators' not in kwargs: - kwargs['separators'] = (',', ':') - - s = jsonmod.dumps(o, **kwargs) - - if isinstance(s, unicode): - s = s.encode('utf8') - - return s - -def loads(s, **kwargs): - """Load object from JSON bytes (utf-8). - - See jsonapi.jsonmod.loads for details on kwargs. - """ - - if str is unicode and isinstance(s, bytes): - s = s.decode('utf8') - - return jsonmod.loads(s, **kwargs) - -__all__ = ['jsonmod', 'dumps', 'loads'] - |