Parse JSON Data

Through this library it is possible to convert JSON structure data to CSV and XML.

Convert JSON to XML example:

const { json } = require('linkapi-sdk/parser');

const data = [{
  id: 2,
  glossary: {
    title: 'example glossary',
    GlossDiv: {
      title: 'S',
      GlossList: {
        GlossEntry: {
          ID: 'SGML',
          SortAs: 'SGML',
          GlossTerm: 'Standard Generalized Markup Language',
          Acronym: 'SGML',
          Abbrev: 'ISO 8879:1986',
          GlossDef: {
            para: 'A meta-markup language, used to create markup languages such as DocBook.',
            GlossSeeAlso: ['GML', 'XML']
          },
          GlossSee: 'markup'
        }
      }
    }
  }
}];

const xml = await json.toXML(data);

Convert JSON to CSV example:

const { json } = require('linkapi-sdk/parser');

const data = [
  {
    Make: 'Nissan',
    Model: 'Murano',
    Year: '2013',
    Specifications: {
      Mileage: '7106',
      Trim: 'S AWD'
    }
  },
  {
    Make: 'BMW',
    Model: 'X5',
    Year: '2014',
    Specifications: {
      Mileage: '3287',
      Trim: 'M'
    }
  }
];

const csv = await json.toCSV(data);