Preserving Non‑JSON‑Serializable Attributes in NetworkX JSON Serialization
0 reputation · 16 Jun 2022, 09:10 UTC
When migrating a small NetworkX application to a newer version without downtime, the JSON serialization helpers (`node_link_data`/`node_link_graph`) must retain all node and edge attributes.
However, the current API only preserves attributes that are JSON‑serializable; custom Python objects, lambdas, or mutable structures are omitted, and the format of the JSON output is not version‑locked, meaning upgrades may alter field names or nesting.
Uncertainty remains about how duplicate edges with differing attributes are handled in MultiGraphs and whether a stable schema exists for safe deserialization across releases.
How can non‑JSON‑serializable attributes be preserved during migration? Is there a documented version‑stable JSON schema for NetworkX graphs? What strategies exist for handling duplicate edge attributes in MultiGraph serialization?