_superjson¶
-
superjson._superjson.
get_class_name_from_dumper_loader_method
(func)[source]¶ Get default value of
class_name
argument.Because the third argument of dumper, loader method must be the class name.
-
superjson._superjson.
is_compressed_json_file
(abspath)[source]¶ Test a file is a valid json file.
*.json
: uncompressed, utf-8 encode json file*.js
: uncompressed, utf-8 encode json file*.gz
: compressed, utf-8 encode json file
-
class
superjson._superjson.
BaseSuperJson
[source]¶ A extensable json encoder/decoder. You can easily custom converter for any types.
-
dumps
(obj, indent: Optional[bool] = None, sort_keys: Optional[bool] = None, pretty: bool = False, float_precision: Optional[int] = None, ensure_ascii: bool = True, compress: bool = False, **kwargs)[source]¶ Dump any object into json string.
-
loads
(s: str, object_hook: Optional[bool] = None, decompress: bool = False, ignore_comments: bool = False, **kwargs)[source]¶ load object from json encoded string.
-
dump
(obj, abspath: str, indent: Optional[bool] = None, sort_keys: Optional[bool] = None, pretty: bool = False, float_precision: Optional[int] = None, ensure_ascii: bool = True, overwrite: bool = False, verbose: bool = True, **kwargs)[source]¶ Dump any object into file.
- Parameters
abspath (str) – if
*.json, *.js**
then do regular dump. if*.gz
, then perform compression.pretty (bool) – if True, dump json into pretty indent and sorted key format.
float_precision (int) – default
None
, limit floats to N-decimal points.overwrite (boolean) – default
False
, IfTrue
, when you dump to existing file, it silently overwrite it. IfFalse
, an alert message is shown. Default settingFalse
is to prevent overwrite file by mistake.verbose (boolean) – default True, help-message-display trigger.
-
load
(abspath: str, object_hook=None, ignore_comments: bool = False, verbose: bool = True, **kwargs)[source]¶ load object from json file.
-