mirror of
https://github.com/python-kasa/python-kasa.git
synced 2024-12-22 19:23:34 +00:00
e233e377ad
* Generate AES KeyPair lazily * Fix coverage * Update post-review * Fix pragma * Make json dumps consistent between python and orjson * Add comment * Add comments re json parameter in HttpClient
20 lines
415 B
Python
Executable File
20 lines
415 B
Python
Executable File
"""JSON abstraction."""
|
|
|
|
try:
|
|
import orjson
|
|
|
|
def dumps(obj, *, default=None):
|
|
"""Dump JSON."""
|
|
return orjson.dumps(obj).decode()
|
|
|
|
loads = orjson.loads
|
|
except ImportError:
|
|
import json
|
|
|
|
def dumps(obj, *, default=None):
|
|
"""Dump JSON."""
|
|
# Separators specified for consistency with orjson
|
|
return json.dumps(obj, separators=(",", ":"))
|
|
|
|
loads = json.loads
|