Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
This is a library designed to render js objects as xml. Its not made to parse or otherwise edit existing xml/html structures.
This is a library designed to render js objects as xml. Its not made to parse or otherwise edit existing xml/html structures. For that and perhaps as a compliment to this you can use jsdom or xml2js for editing existing markup.
this will do a good job rendering json as xml but apis that require xml expect odd things mostly related to elements with attributes and implicit array like keys that make formatting your json a little tricky.
var jsonxml = require('jsontoxml');
var xml = jsonxml({
node:'text content',
parent:[
{name:'taco',text:'beef taco',children:{salsa:'hot!'}},
{name:'taco',text:'fish taco',attrs:{mood:'sad'},children:[
{name:'salsa',text:'mild'},
'hi',
{name:'salsa',text:'weak',attrs:{type:2}}
]},
{name:'taco',attrs:'mood="party!"'}
],
parent2:{
hi:'is a nice thing to say',
node:'i am another not special child node'
date:function(){
return (new Date())+'';
}
}
})
console.log(xml);
outputs:
<node>text content</node>
<parent>
<taco>
beef taco
<salsa>hot!</salsa>
</taco>
<taco mood='sad'>
fish taco
<salsa>mild</salsa>
hi
<salsa type="2">weak</salsa>
</taco>
<taco mood='party!'/>
</parent>
<parent2>
<hi>is a nice thing to say</hi>
<node>i am another not special child node</node>
<date>Sun Sep 26 2010 17:27:29 GMT-0700 (PDT)</date>
</parent2>
jsontoxml (obj,options)
options
is optional. it can be true (add generic xml header) or an object. If an object, valid options are:
escape
xmlHeader
can either be boolan (add generic <?xml …?>
header) or an object. If an object valid options are:
standalone
if true, the <?xml …?>
gets an additional attribute standalone="true"
.docType
if defined gets added as the <!DOCTYPE …>
contents (unescaped).prettyPrint
if truthy the output gets a rudimentary pretty print (good for debugging, don't expect too much)jsontoxml.escape (string)
"" & < >
jsontoxml.cdata (string)
<!CDATA[[ ]]>
]]>
) in input textI made this because i wanted to abstract away the fact that antiquated external systems require post data as xml and i wanted to expose a standard js calling api like my other interfaces.
I did not want to instantiate an entire dom to perform simple updates to tags in lower level functions (like injecting api keys) when top level api call specific functions start building the xml string.
FAQs
This is a library designed to render js objects as xml. Its not made to parse or otherwise edit existing xml/html structures.
The npm package jsontoxml receives a total of 17,547 weekly downloads. As such, jsontoxml popularity was classified as popular.
We found that jsontoxml demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.