Skip to content

convert json object to xml and xml string to json object

Notifications You must be signed in to change notification settings

payneal/json_xml_converter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON XML Converter

to run test

  • git clone repo
  • cd xml_and_json
  • npm install
  • npm run test

how libary works

  • to create converter ex.
    const Converter = require('../json_to_xml_converter');
    let  converter = new Converter();
  • to convert a json object to xml
    var args = JSON_OBJECT 
    var json_object  = converter.json_to_xml(args);
  • to convert xml to json object
    var args = XML_STRING
    var xml_string = converter.xml_to_json(args);
  • to tell converter that the xml string you are passing in has array elements
        var args = {
        	umm: {
            	attributes: { 
                	x: '10',                               
                },
				hold: [
					{count:"0"},
					{count:"1"}
				]
         	}
		};

		var valid_xml = `
			<umm x="10">
   				<hold>
        			<count>0</count>
        			<count>1</count>
    			</hold>
			</umm>`

       	converter.add_elements_that_are_arrays(["hold"]);
        var xml = converter.json_to_xml(args);
        expect(valid_xml).xml.to.equal(xml);
	});
  • to clear the array possibilities for xml to json
    converter.clear_xml_array_name();
  • needs another featuer implemented to handdle xml array within an array element
    //not implemented

About

convert json object to xml and xml string to json object

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published