Skip to content

ele.json()

eles.json — Collection > Metadata and identity. Cytoscape.js signatures, parameters and return contract.

eles.json — Collection › Metadata and identity

Preview · Collection › Metadata and identity

Read in the complete API reference · All API members

// Plain-object form of the first element (undefined when empty)
ele.json(): Record<string, unknown> | undefined

Plain-object form of the first element (undefined when empty).

Returns Record<string, unknown> | undefined

the definition-form object for the first element, or undefined when the collection is empty; it round-trips through cy.add(), which is the supported restore path because cy.json() is export-only

Example

console.log(cy.getElementById('a').json().data.id); // 'a'

Example graph and handle setup