JgfJsonDecorator

JgfJsonDecorator

Transforms graphs or multi graphs to json or vice versa. Note that this is just called decorator for semantic reasons and does not follow and does not intend to follow the GoF decorator design pattern.

Constructor

new JgfJsonDecorator()

Source:

Methods

(static) fromJson(json) → {JgfGraph|JgfMultiGraph}

Source:
Creates a Jgf graph or multi graph from JSON.
Parameters:
Name Type Description
json object JSON to be transformed to a graph or multigraph. This has to be according to the JGF.
Throws:
Error if json can not be transformed to a graph or multi graph.
Returns:
The created Jgf graph or multi graph object.
Type
JgfGraph | JgfMultiGraph

(static) toJson(graph) → {object}

Source:
Transforms either a graph or a multi graph object to a JSON representation as per the spec.
Parameters:
Name Type Description
graph JgfGraph | JgfMultiGraph The graph to be transformed to JSON.
Throws:
Error if the passed graph or multi graph can not be transformed to JSON.
Returns:
A JSON representation of the passed graph or multi graph as according to the JGF.
Type
object