JSPM

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

Converts xml to json and viceverza, using node-expat.

Package Exports

  • xml2json

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 (xml2json) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Simple SAX-based XML2JSON Parser.

It does not parse the following elements:

  • CDATA sections
  • Processing instructions
  • XML declarations
  • Entity declarations
  • Comments

Installation

npm install xml2json

Usage

var parser = require('xml2json');

var xml = "<foo>bar</foo>";
var json = parser.toJson(xml); //returns an string containing the json structure by default
console.log(json);
  • if you want to get the Javascript object then you might want to invoke parser.toJson(xml, {object: true});
  • if you want a reversible json to xml then you should use parser.toJson(xml, {reversible: true});

License

Copyright 2011 BugLabs Inc. All rights reserved.