Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
@titanium/xml2json
Advanced tools
Readme
🪦 RIP Axway Amplify Titanium (2010 - 2022)
🪦 RIP Axway Amplify Cloud Services (2012 - 2022)
🪦 RIP Axway Amplify Crash Analytics (2015 - 2022)
👉 A group of Axway employees, ex-Axway employees, and some developers from Titanium community have created a legal org and now officially decide all matters related to future of these products.
Configurable, lightweight XML to JSON converter for Titanium native mobile apps. Based on https://github.com/metatribal/xmlToJSON by metatribal
Install using npm:
npm install @titanium/xml2json
const xml2json = require('@titanium/xml2json');
const testString = '<xml><a>It Works!</a></xml>'; // get some xml (string or document/node)
const result = xml2json.parseString(testString); // parse
The (prettified) result of the above code is
{
"xml": {
"a": [
{
"text": "It Works!"
}
]
}
}
// These are the option defaults
var options = {
mergeCDATA: true, // extract cdata and merge with text nodes
grokAttr: true, // convert truthy attributes to boolean, etc
grokText: true, // convert truthy text/attr to boolean, etc
normalize: true, // collapse multiple spaces to single space
xmlns: true, // include namespaces as attributes in output
namespaceKey: '_ns', // tag name for namespace objects
textKey: '_text', // tag name for text nodes
valueKey: '_value', // tag name for attribute values
attrKey: '_attr', // tag for attr groups
cdataKey: '_cdata', // tag for cdata nodes (ignored if mergeCDATA is true)
attrsAsObject: true, // if false, key is used as prefix to name, set prefix to '' to merge children and attrs.
stripAttrPrefix: true, // remove namespace prefixes from attributes
stripElemPrefix: true, // for elements of same name in diff namespaces, you can enable namespaces and access the nskey property
childrenAsArray: true // force children into arrays
};
// you can change the defaults by passing the parser an options object of your own
var myOptions = {
mergeCDATA: false,
xmlns: false,
attrsAsObject: false
}
result = xml2json.parseString(xmlString, myOptions);
A more complicated example (with xmlns: true)
<?xml version="1.0" encoding="UTF-8"?>
<xml xmlns="http://default.namespace.uri">
<a>
<b id="1">one</b>
<b id="2"><![CDATA[some <cdata>]]>two</b>
<ns:c xmlns:ns="http://another.namespace" ns:id="3">three</ns:c>
</a>
</xml>
results in
{
"xml": [{
"attr": {
"xmlns": {
"value": "http://default.namespace.uri"
}
},
"a": [{
"b": [{
"attr": {
"id": {
"value": 1
}
},
"text": "one"
}, {
"attr": {
"id": {
"value": 2
}
},
"text": "some <cdata>two"
}],
"c": [{
"attr": {
"xmlns:ns": {
"value": "http://another.namespace"
},
"id": {
"value": 3
}
},
"text": "three"
}]
}]
}]
}
Have an idea or a comment? Join in the conversation here!
Alloy is developed by Appcelerator and the community and is Copyright © 2012-Present by Appcelerator, Inc. All Rights Reserved.
Alloy is made available under the Apache Public License, version 2. See their license file for more information.
Appcelerator is a registered trademark of Appcelerator, Inc. Titanium is a registered trademark of Appcelerator, Inc. Please see the LEGAL information about using trademarks, privacy policy, terms of usage and other legal information at http://www.appcelerator.com/legal.
FAQs
⭐ Axway Amplify module to convert XML to JSON for Appcelerator Titanium apps
The npm package @titanium/xml2json receives a total of 10 weekly downloads. As such, @titanium/xml2json popularity was classified as not popular.
We found that @titanium/xml2json demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.