smartxml/ts/index.ts

16 lines
437 B
TypeScript
Raw Normal View History

2020-10-24 15:47:12 +00:00
import * as plugins from './smartxml.plugins';
2020-10-24 16:39:37 +00:00
export class SmartXml {
constructor() {}
public parseXmlToObject<T = any>(xmlStringArg: string): T {
2020-10-24 21:03:51 +00:00
const jsonObject = plugins.fastXmlParser.parse(xmlStringArg);
2020-10-24 16:39:37 +00:00
return jsonObject;
}
public createXmlFromObject(jsObject: any): string {
const jsToXmlParser = new plugins.fastXmlParser.j2xParser({});
const xml = jsToXmlParser.parse(jsObject);
return xml;
}
}