Files
js_api_module/convertxml/js_convertxml.js
T
lifansheng e0805f6495 modify codecheck
Signed-off-by: lifansheng <lifansheng1@huawei.com>
2021-09-15 09:47:57 +08:00

39 lines
1.1 KiB
JavaScript
Executable File

/*
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
'use strict';
const convertXml = requireInternal("ConvertXML");
class ConvertXml {
convertxmlclass;
constructor() {
this.convertxmlclass = new convertXml.ConvertXml();
}
convert(strXml, options) {
let converted = this.convertxmlclass.convert(strXml, options);
let space = 0;
if (converted.hasOwnProperty("spaces")) {
space = converted.spaces;
delete converted.spaces;
}
return JSON.stringify(converted, null, space);
}
}
export default {
ConvertXml : ConvertXml
}