Git Product home page Git Product logo

node-xmljson's Introduction

xmljson

Translates between JSON and XML formats

Build Status

Getting Started

Install the module with: npm install xmljson

Convert XML to JSON

// Load the module
var to_json = require('xmljson').to_json;

// An XML string
var xml = '' +
	'<data>' +
		'<prop1>val1</prop1>' +
		'<prop2>val2</prop2>' +
		'<prop3>val3</prop3>' +
	'</data>';

to_json(xml, function (error, data) {
	// Module returns a JS object
	console.log(data);
	// -> { prop1: 'val1', prop2: 'val2', prop3: 'val3' }

	// Format as a JSON string
	console.log(JSON.stringify(data));
	// -> {"prop1":"val1","prop2":"val2","prop3":"val3"}
});

Convert JSON to XML

// Load the module
var to_xml = require('xmljson').to_xml;

// A JSON string
var json = '' +
	'{' +
		'"prop1":"val1",' +
		'"prop2":"val2",' +
		'"prop3":"val3"' +
	'}';

to_xml(json, function (error, xml) {
	// Module returns an XML string
	console.log(xml);
	// -> <data><prop1>val1</prop1><prop2>val2</prop2><prop3>val3</prop3></data>
});

Release History

This module is semantically versioned: http://semver.org

Version 0.2.0 2013-07-27

  • Support child elements where some have duplicate names and some do not

Version 0.1.0 2013-05-29

  • Initial release

Contributing

Before writing code, we suggest you search for issues or create a new one to confirm where your contribution fits into our roadmap.

In lieu of a formal style guide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.

##Authors

Adam Alexander

Benjamin Dean

Copyright and license

Copyright (c) 2013 ExactTarget

Licensed under the MIT License (the "License"); you may not use this work except in compliance with the License. You may obtain a copy of the License in the COPYING file.

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

node-xmljson's People

Contributors

adamalex avatar creatovisguru avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.