toJSON
方法返回一个 JSON 字符串,其中包含 Edge 对象的所有属性。
edge.toJSON();
返回一个包含 Edge 对象所有属性的 JSON 字符串。
const edge = new Edge({
source: "node1",
target: "node2",
label: "Edge Label",
color: "#ff0000"
});
console.log(edge.toJSON());
输出:
{
"source": "node1",
"target": "node2",
"label": "Edge Label",
"color": "#ff0000"
}