After coming across this interesting question and answer, I decided to create this JSFiddle to explore further.
My objective is to find an effective way to export and import JSON data into cytoscape.js.
The approach I took involved using JSON.stringify(cy.json())
to retrieve the JSON data from elements. On the other hand, I cleared the cy
component and utilized cy.add(text-input)
to reintroduce the elements.
For example, you can add a node, copy its generated JSON data, refresh the browser, and then try pasting the JSON data directly into the cy
component. However, despite my efforts, I couldn't get it to work. I suspect the issue lies in my usage of the cy.add
function, as I keep encountering these two errors:
An element must be of type 'nodes' or 'edges'; you specified 'undefined'
Uncaught TypeError: Cannot read property 'single' of undefined
Any insights or suggestions would be greatly appreciated.
Thank you in advance.