Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5481831711 | |||
| fb606e734b |
2
package-lock.json
generated
2
package-lock.json
generated
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartxml",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartxml",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"private": false,
|
||||
"description": "a package for creating and parsing xml formated files",
|
||||
"main": "dist_ts/index.js",
|
||||
|
||||
@@ -17,7 +17,8 @@ tap.test('should create an xml string', async () => {
|
||||
hello: {
|
||||
"@_xlmns:teststring": "hellothere",
|
||||
"@_xlmns:testnumber": 10,
|
||||
wow: 'test'
|
||||
wow: 'test',
|
||||
url: [{loc: 3},{loc: 3}]
|
||||
}
|
||||
});
|
||||
console.log(xmlResult);
|
||||
|
||||
@@ -11,9 +11,11 @@ export class SmartXml {
|
||||
public createXmlFromObject(jsObject: any): string {
|
||||
const jsToXmlParser = new plugins.fastXmlParser.j2xParser({
|
||||
ignoreAttributes: false,
|
||||
attributeNamePrefix: "@_"
|
||||
attributeNamePrefix: "@_",
|
||||
format: true,
|
||||
indentBy: ' ',
|
||||
});
|
||||
const xml = jsToXmlParser.parse(jsObject);
|
||||
return xml;
|
||||
return '<?xml version="1.0" encoding="UTF-8"?>\n' + xml;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user