msl.network.json module
This module is used as the JSON (de)serializer.
- class msl.network.json.Package(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]
Bases:
Enum
Supported Python packages for (de)serializing JSON objects.
By default, the builtin
json
module is used.To change which JSON package to use you can call
use()
to set the backend during runtime, or you can specify anMSL_NETWORK_JSON
environment variable as the default backend. For example, creating an environment variable namedMSL_NETWORK_JSON
and setting its value to beULTRA
would use UltraJSON to (de)serialize JSON objects.Changed in version 1.0: Moved from the
msl.network.constants
module and renamed. AddedJSON
,UJSON
,RAPIDJSON
andSIMPLEJSON
aliases. AddedOR
(and aliasORJSON
) for orjson. RemovedYAJL
.- SIMPLE = 'SIMPLE'
- SIMPLEJSON = 'SIMPLE'
- msl.network.json.use(value)[source]
Set which JSON backend to use.
New in version 1.0.
Examples
>>> from msl.network import json >>> json.use(json.Package.UJSON) >>> json.use('ujson')