If you build from the source (or use 2.1 when released), you can use eles.jsons()
, which gives an array of element JSONs. You're calling cy.json()
, which gives the entire graph init options JSON -- which you can't pass to cy.add()
or similar.
Alternatively to eles.jsons()
, you can use the already existing ele.json()
and build up an array yourself by iterating over the elements.
You also need to pass the objects to cy.add()
etc. You can't pass a JSON string.
e.g.
cy.add( JSON.parse( jsonString ) )