Skip to content

how to export to json then re-import? #4

@j2l

Description

@j2l

Hello Sir,

To save/export as JSON, I tried changing the save function to:

async save () {
    try {
      let blob = await this.cy.json(false, 'elements')
      if (window.navigator.msSaveBlob) {
        window.navigator.msSaveBlob(blob, `chart-${Date.now()}.json`)
      } else {
        let a = document.createElement('a')
        a.download = `chart-${Date.now()}.json`
        a.href = window.URL.createObjectURL(blob)
        a.click()
      }
    } catch (e) {
      console.log(e)
    }
  }

but I get an error about the createObjectURL:

TypeError: URL.createObjectURL: Argument 1 is not valid for any of the 1-argument overloads.
    save index.js:513
    _handleCommand index.js:359
    _loop2 cytoscape.cjs.js:10505
    trigger cytoscape.cjs.js:10517
    forEachEventObj cytoscape.cjs.js:10401
    trigger cytoscape.cjs.js:10475
    emit cytoscape.cjs.js:14157
    command index.js:59
    _initEvents index.js:62
    Toolbar index.js:32
    default index.js:140
    _initPlugin index.js:245
    _init index.js:43
    CyEditor index.js:36
    mounted cyeditor.js:38
    VueJS 11
    <anonymous> main.js:8
    js app.js:864
    __webpack_require__ app.js:724
    fn app.js:101
    1 app.js:1995
    __webpack_require__ app.js:724
    <anonymous> app.js:791
    <anonymous> app.js:794

How would I add export to JSON and import as JSON buttons?

Thank you

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions