USGSCSM
U.S. flag

An official website of the United States government

Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

io.io_json — JSON Wrapper

The io.io_json module provides a convenience wrapper to access JSON .. versionadded:: 0.1.0

class plio.io.io_json.NumpyEncoder(*, skipkeys=False, ensure_ascii=True, check_circular=True, allow_nan=True, sort_keys=False, indent=None, separators=None, default=None)[source]
default(obj)[source]

Implement this method in a subclass such that it returns a serializable object for o, or calls the base implementation (to raise a TypeError).

For example, to support arbitrary iterators, you could implement default like this:

def default(self, o):
    try:
        iterable = iter(o)
    except TypeError:
        pass
    else:
        return list(iterable)
    # Let the base class default method raise the TypeError
    return JSONEncoder.default(self, o)
plio.io.io_json.read_json(inputfile)[source]

Read the input json file into a python dictionary.

Parameters:

inputfile (str) – PATH to the file on disk

Returns:

jobs – returns a dictionary

Return type:

dict

plio.io.io_json.write_json(outdata, outputfile)[source]

Write a Python dictionary as a plain-text JSON file

Parameters:
  • outdata (dict) – The data structure to be serialized

  • outputfile (str) – The file to write the data to.