sciris.sc_fileio.loadjson

loadjson(filename=None, folder=None, string=None, fromfile=True, **kwargs)[source]

Convenience function for reading a JSON file (or string).

Parameters
  • filename (str) – the file to load, or the JSON object if using positional arguments

  • folder (str) – folder if not part of the filename

  • string (str) – if not loading from a file, a string representation of the JSON

  • fromfile (bool) – whether or not to load from file

  • kwargs (dict) – passed to json.load()

Returns

the JSON object

Return type

output (dict)

Examples:

json = sc.loadjson('my-file.json')
json = sc.loadjson(string='{"a":null, "b":[1,2,3]}')