"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const fs_1 = require("fs"); const xml2js_1 = require("xml2js"); var xml = ''; const xmlOptions = { explicitArray: false, explicitRoot: false, attrkey: '@', charkey: '#', mergeAttrs: false, }; const convertXmlToJson = (xmlPath, jsonPath) => __awaiter(void 0, void 0, void 0, function* () { // ✅ use "utf8" – the correct BufferEncoding value const xmlData = (0, fs_1.readFileSync)(xmlPath, { encoding: 'utf8' }); const result = yield (0, xml2js_1.parseStringPromise)(xmlData, xmlOptions); console.dir(result); const jsonString = JSON.stringify(result, null, 2); (0, fs_1.writeFileSync)(jsonPath, jsonString, { encoding: 'utf8' }); console.log(`✅ JSON written to ${jsonPath}`); }); const xmlFile = 'input2.xml'; const jsonFile = 'output.json'; convertXmlToJson(xmlFile, jsonFile).catch(err => { console.error('❌ conversion failed:', err); }); //# sourceMappingURL=convert-xml-to-json.js.map