SDK - Parser

Used to convert data such as XML to JSON. or JSON to CSV.

JSON

JSON to XML

To convert JSON to XML use the following example:

const { json } = require('@linkapi.solutions/nodejs-sdk/parser');
const jsonToParse = {
name: 'John'
};
const xml = await json.toXML(jsonToParse);

JSON to CSV

To convert JSON to CSV use the following example:

const { json } = require('@linkapi.solutions/nodejs-sdk/parser');
const jsonToParse = {
name: 'John'
};
const csv = await json.toCSV(jsonToParse);

XML

XML to JSON

To convert XML to JSON use the following example:

const { xml } = require('@linkapi.solutions/nodejs-sdk/parser');
const xmlToParse = `
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
`;
const jsonParsed = await xml.toJSON(xmlToParse);

CSV

CSV to JSON

To convert XML to JSON use the following example:

const { csv } = require('@linkapi.solutions/nodejs-sdk/parser');
const csvToParse = `
a,b,c
1,2,3
4,5,6
`;
const jsonParsed = await csv.toJSON(csvToParse);