How to use the json2csv function in json2csv

To help you get started, we’ve selected a few json2csv examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github amerker / google-keep-converter / test / saver.spec.js View on Github external
test('JSON and CSV files are written and match with input data', (t) => {
  writeFile(notesStub, true, 'bar');

  const jsonFileContent = fs.readFileSync('bar.json', 'utf-8');
  t.deepEqual(JSON.parse(jsonFileContent), notesStub);

  t.notThrows(() => {
    fs.lstatSync('bar.csv');
  });

  const csvFileContent = fs.readFileSync('bar.csv', 'utf-8');
  t.is(csvFileContent, json2csv({ data: notesStub }));
});
github MoveOnOrg / Spoke / dev-tools / generate-contacts.js View on Github external
const fields = ["firstName", "lastName", "cell", "companyName", "city", "zip"];
const numContacts = 10000;

const data = [];
for (let index = 0; index < numContacts; index++) {
  data.push({
    firstName: faker.name.firstName(),
    lastName: faker.name.lastName(),
    cell: `1-${faker.phone.phoneNumberFormat()}`,
    companyName: faker.company.companyName(),
    city: faker.address.city(),
    zip: faker.address.zipCode()
  });
}

const csvFile = json2csv({ data, fields });
console.log(csvFile);
github binary-com / binary-bot / src / botPage / view / LogTable.js View on Github external
export() {
        const data = json2csv({ data: this.state.rows, fields: ['timestamp', 'message'] });
        saveAs({ data, filename: 'logs.csv', type: 'text/csv;charset=utf-8' });
    }
    render() {
github Autodesk-Forge / forge-rcdb.nodejs / src / server / api / endpoints / meta.js View on Github external
externalId: prop.externalId,
              component: prop.component,
              metaType: prop.metaType,
              filelink: prop.filelink,
              filename: prop.filename,
              link: prop.link
            }
          })

          res.header('Content-Type','application/json')
          res.send(JSON.stringify(exportedProps, null, 2))
          break

        case 'csv':

          const csv = json2csv({
            fields: [
              'externalId',
              'component',
              'displayCategory',
              'displayName',
              'displayValue',
              'metaType',
              'filelink',
              'filename',
              'link'
            ],
            data: properties
          })
          res.header('Content-Type','application/text')
          res.send(csv)
          break
github kalisio / krawler / src / hooks / hooks.csv.js View on Github external
return async function (hook) {
    if (hook.type !== 'after') {
      throw new Error('The \'writeCSV\' hook should only be used as a \'after\' hook.')
    }

    const store = await getStoreFromHook(hook, 'writeCSV', options)

    debug('Creating CSV for ' + hook.data.id)
    const data = _.get(hook, options.dataPath || 'result')
    const csv = json2csv({ data, fields: options.fields })
    const csvName = template(hook.data, options.key || (hook.data.id + '.csv'))
    await writeBufferToStore(
      Buffer.from(csv, 'utf8'),
      store, {
        key: csvName,
        params: options.storageOptions
      }
    )
    addOutput(hook.result, csvName, options.outputType)
    return hook
  }
}
github binary-com / binary-bot / src / botPage / view / TradeInfoPanel / TradeTable.js View on Github external
export() {
        const { accountID } = this.props;

        const data = json2csv({
            data  : this.state[accountID].rows,
            fields: [
                'id',
                'timestamp',
                'reference',
                'contract_type',
                'entry_tick',
                'exit_tick',
                'buy_price',
                'sell_price',
                'profit',
            ],
        });
        saveAs({ data, filename: 'logs.csv', type: 'text/csv;charset=utf-8' });
    }
    getAccountStat(accountID) {
github binary-com / binary-bot / src / botPage / view / LogTable.js View on Github external
export() {
        const data = json2csv({ data: this.state.rows, fields: ['timestamp', 'message'] });
        saveAs({ data, filename: 'logs.csv', type: 'text/csv;charset=utf-8' });
    }
    render() {
github odota / web / src / components / Explorer / index.jsx View on Github external
secondary
            target="_blank"
            style={{ margin: '5px' }}
            label={strings.explorer_schema}
            href="https://github.com/odota/core/blob/master/sql/create_tables.sql"
          />
          <span style="{{">
            
            {/*
          
          
          
          */}
             field.name),
            }))}`}
              download="data.csv"
              context={explorer}
            /&gt;
            
             window.open(`${process.env.REACT_APP_API_HOST}/api/explorer?sql=${encodeURIComponent(getSqlString())}`, '_blank')}
              context={explorer}</span>

json2csv

Convert JSON to CSV

MIT
Latest version published 1 year ago

Package Health Score

74 / 100
Full package analysis