_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_dumper_method(func)[source]

Test if it is a dumper method.

superjson._superjson.is_loader_method(func)[source]

Test if it is a loader method.

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=None, sort_keys=None, pretty=False, float_precision=None, ensure_ascii=True, compress=False, **kwargs)[source]

Dump any object into json string.

Parameters
  • pretty (bool) – if True, dump json into pretty indent and sorted key format.

  • float_precision (integer) – default None, limit floats to N-decimal points.

  • compress (bool) – default False. If True, then compress encoded string.

loads(s, object_hook=None, decompress=False, ignore_comments=False, **kwargs)[source]

load object from json encoded string.

Parameters
  • decompress (bool) – default False. If True, then decompress string.

  • ignore_comments (bool) – default False. If True, then ignore comments.

dump(obj, abspath, indent=None, sort_keys=None, pretty=False, float_precision=None, ensure_ascii=True, overwrite=False, verbose=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 (integer) – default None, limit floats to N-decimal points.

  • overwrite (boolean) – default False, If True, when you dump to existing file, it silently overwrite it. If False, an alert message is shown. Default setting False is to prevent overwrite file by mistake.

  • verbose (boolean) – default True, help-message-display trigger.

load(abspath, object_hook=None, ignore_comments=False, verbose=True, **kwargs)[source]

load object from json file.

Parameters
  • abspath (str) – if *.json, *.js** then do regular dump. if ``*.gz, then perform decompression.

  • ignore_comments (bool) – default ``False. If True, then ignore comments.

  • verbose (boolean) – default True, help-message-display trigger.

class superjson._superjson.SuperJson[source]