Class GraphJsonExtensions
- Namespace
- Graph1x.Serialization
- Assembly
- Graph1x.dll
Exports graphs to JSON in the node-link shape used across the ecosystem
(NetworkX, D3): { "directed": ..., "nodes": [...], "edges": [...] }.
Written with Utf8JsonWriter directly — no reflection-based
serialization — with deterministic property order and invariant number
formatting.
public static class GraphJsonExtensions
- Inheritance
-
GraphJsonExtensions
- Inherited Members
Methods
ToJson<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>)
Renders the graph as node-link JSON with default options.
public static string ToJson<TVertex, TEdge>(this IReadOnlyGraph<TVertex, TEdge> graph) where TVertex : notnull where TEdge : IEdge<TVertex>
Parameters
graphIReadOnlyGraph<TVertex, TEdge>The graph to render.
Returns
- string
The JSON document text.
Type Parameters
TVertexThe vertex type.
TEdgeThe edge type.
ToJson<TVertex, TEdge>(IReadOnlyGraph<TVertex, TEdge>, GraphJsonExportOptions<TVertex, TEdge>)
Renders the graph as node-link JSON.
public static string ToJson<TVertex, TEdge>(this IReadOnlyGraph<TVertex, TEdge> graph, GraphJsonExportOptions<TVertex, TEdge> options) where TVertex : notnull where TEdge : IEdge<TVertex>
Parameters
graphIReadOnlyGraph<TVertex, TEdge>The graph to render.
optionsGraphJsonExportOptions<TVertex, TEdge>Rendering options.
Returns
- string
The JSON document text.
Type Parameters
TVertexThe vertex type.
TEdgeThe edge type.
Exceptions
- ArgumentNullException
Either argument is null.