mirror of
https://github.com/rembo10/headphones.git
synced 2026-01-13 08:47:57 -05:00
Mostly just updating libraries, removing string encoding/decoding, fixing some edge cases. No new functionality was added in this commit.
26 lines
440 B
Python
26 lines
440 B
Python
"""
|
|
JSON support.
|
|
|
|
Expose preferred json module as json and provide encode/decode
|
|
convenience functions.
|
|
"""
|
|
|
|
try:
|
|
# Prefer simplejson
|
|
import simplejson as json
|
|
except ImportError:
|
|
import json
|
|
|
|
|
|
__all__ = ['json', 'encode', 'decode']
|
|
|
|
|
|
decode = json.JSONDecoder().decode
|
|
_encode = json.JSONEncoder().iterencode
|
|
|
|
|
|
def encode(value):
|
|
"""Encode to bytes."""
|
|
for chunk in _encode(value):
|
|
yield chunk.encode('utf-8')
|