Skip to content

JSON and NDJSON

Read and write a graph as a JSON-compatible dictionary, or as newline-delimited JSON (NDJSON) files.

annnet.io.json_format.from_json

from_json(path)

Load AnnNet from node-link JSON + x-extensions (lossless wrt schema above).

annnet.io.json_format.to_json

to_json(graph, path, *, public_only=False, indent=0)

Node-link JSON with x-extensions (slices, edge_slices, hyperedges).

Preserves IDs, attributes, parallel edges, hyperedges and slices.

annnet.io.json_format.read_ndjson

read_ndjson(dir_path, *, sidecar='auto')

Read the directory write_ndjson wrote.

annnet.io.json_format.write_ndjson

write_ndjson(graph, dir_path, *, sidecar=True)

Write nodes.ndjson, edges.ndjson, hyperedges.ndjson, slices.ndjson, edge_slices.ndjson.

Each line is one JSON object. Lossless wrt to_json schema.