JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q28522F
  • License MIT

This package converts xml string into json and returns the json object as output.

Package Exports

  • xmlintojson
  • xmlintojson/xmlintojson.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (xmlintojson) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

xmlintojson

This js converts xml string into json object

Instruction

  1. Include/Require the xmlintojson.js file
var converter = require('./xmlintojson.js');
  1. Pass the xml string to the function and save the json object response
var xml = "<parent><child></child></parent>";
var json = converter(xml);

Output Format

Below is an example xml used to convert into json:

<?xml version='1.0' encoding='UTF-8'?>
<Order Id='544'>
    <orderID>81</orderID>
    <sessionID>CORRELATION-3baee8b0-b483-47aa-89b2-bf7b03d0c41f</sessionID>
    <orderlines Id='545'>
        <lineID>1</lineID>
        <productID>CFS TV</productID>
        <action>PROVIDE</action>
        <quantity>1.0</quantity>
        <requiredByDate>2011-04-30T23:50:00+05:30</requiredByDate>
        <LineUsed>false</LineUsed>
        <OrderlinesUDF Id='546'>
            <name>OrderRef</name>
            <value>OrderRefID</value>
            <flavor>input</flavor>
        </OrderlinesUDF>
    </orderlines>
    <orderlines Id='547'>
        <lineID>2</lineID>
        <productID>CFS Live Box</productID>
        <action>PROVIDE</action>
        <quantity>1.0</quantity>
        <requiredByDate>2011-04-30T23:50:00+05:30</requiredByDate>
        <LineUsed>false</LineUsed>
        <OrderlinesUDF Id='548'>
            <name>OrderRef</name>
            <value>OrderRefID</value>
            <flavor>input</flavor>
        </OrderlinesUDF>
    </orderlines>
    <orderlines Id='549'>
        <lineID>3</lineID>
        <productID>CFS VOIP</productID>
        <action>PROVIDE</action>
        <quantity>1.0</quantity>
        <requiredByDate>2011-04-30T23:50:00+05:30</requiredByDate>
        <LineUsed>false</LineUsed>
        <OrderlinesUDF Id='550'>
            <name>OrderRef</name>
            <value>OrderRefID</value>
            <flavor>input</flavor>
        </OrderlinesUDF>
    </orderlines>
    <status>NewOrder</status>
    <currentTime>2012-07-18T10:19:03+05:30</currentTime>
    <TineDelay>0</TineDelay>
    <customerref>Apple</customerref>
    <OrderHeaderUDF Id='551'>
        <name>Company</name>
        <value>Orange</value>
        <flavor>input</flavor>
    </OrderHeaderUDF>
    <Originator>Orchestrator</Originator>
    <OrderRef>OrderRefID</OrderRef>
    <businessTransactionID>a7eb1e1de1fa45c993f65589dba70648</businessTransactionID>
</Order>


Converted output:

{
    "xml": {
        "__version": "1.0",
        "__encoding": "UTF-8"
    },
    "Order": {
        "orderID": "81",
        "sessionID": "CORRELATION-3baee8b0-b483-47aa-89b2-bf7b03d0c41f",
        "orderlines": [
            {
                "lineID": "1",
                "productID": "CFS TV",
                "action": "PROVIDE",
                "quantity": "1.0",
                "requiredByDate": "2011-04-30T23:50:00+05:30",
                "LineUsed": "false",
                "OrderlinesUDF": {
                    "name": "OrderRef",
                    "value": "OrderRefID",
                    "flavor": "input",
                    "__Id": "546"
                },
                "__Id": "545"
            },
            {
                "lineID": "2",
                "productID": "CFS Live Box",
                "action": "PROVIDE",
                "quantity": "1.0",
                "requiredByDate": "2011-04-30T23:50:00+05:30",
                "LineUsed": "false",
                "OrderlinesUDF": {
                    "name": "OrderRef",
                    "value": "OrderRefID",
                    "flavor": "input",
                    "__Id": "548"
                },
                "__Id": "547"
            },
            {
                "lineID": "3",
                "productID": "CFS VOIP",
                "action": "PROVIDE",
                "quantity": "1.0",
                "requiredByDate": "2011-04-30T23:50:00+05:30",
                "LineUsed": "false",
                "OrderlinesUDF": {
                    "name": "OrderRef",
                    "value": "OrderRefID",
                    "flavor": "input",
                    "__Id": "550"
                },
                "__Id": "549"
            }
        ],
        "status": "NewOrder",
        "currentTime": "2012-07-18T10:19:03+05:30",
        "TineDelay": "0",
        "customerref": "Apple",
        "OrderHeaderUDF": {
            "name": "Company",
            "value": "Orange",
            "flavor": "input",
            "__Id": "551"
        },
        "Originator": "Orchestrator",
        "OrderRef": "OrderRefID",
        "businessTransactionID": "a7eb1e1de1fa45c993f65589dba70648",
        "__Id": "544"
    }
}