Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e75a939214 | |||
| deda012e03 |
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartxml",
|
"name": "@pushrocks/smartxml",
|
||||||
"version": "1.0.4",
|
"version": "1.0.5",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartxml",
|
"name": "@pushrocks/smartxml",
|
||||||
"version": "1.0.4",
|
"version": "1.0.5",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a package for creating and parsing xml formated files",
|
"description": "a package for creating and parsing xml formated files",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ tap.test('should create an instance', async () => {
|
|||||||
tap.test('should create an xml string', async () => {
|
tap.test('should create an xml string', async () => {
|
||||||
const xmlResult = testSmartxml.createXmlFromObject({
|
const xmlResult = testSmartxml.createXmlFromObject({
|
||||||
hello: {
|
hello: {
|
||||||
|
"@_xlmns:teststring": "hellothere",
|
||||||
|
"@_xlmns:testnumber": 10,
|
||||||
wow: 'test'
|
wow: 'test'
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -9,7 +9,10 @@ export class SmartXml {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public createXmlFromObject(jsObject: any): string {
|
public createXmlFromObject(jsObject: any): string {
|
||||||
const jsToXmlParser = new plugins.fastXmlParser.j2xParser({});
|
const jsToXmlParser = new plugins.fastXmlParser.j2xParser({
|
||||||
|
ignoreAttributes: false,
|
||||||
|
attributeNamePrefix: "@_"
|
||||||
|
});
|
||||||
const xml = jsToXmlParser.parse(jsObject);
|
const xml = jsToXmlParser.parse(jsObject);
|
||||||
return xml;
|
return xml;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user