/** * JsonToXml — JSON → XML conversion * ──────────────────────────────────── * Converts a plain JavaScript object (JSON-serialisable) into an XmlDocument * or an XML string. * * Conversion rules * ──────────────── * • Object keys become element tag names * • Keys with the configured attribute prefix become attributes * • The configured text key becomes a text node * • Array values produce repeated sibling elements * • Primitive values (string / number / boolean) become text nodes * • null values produce an empty self-closing element * * Usage * ───── * import { jsonToXml, jsonToXmlString } from 'xml-xsd-engine/transform'; * * const doc = jsonToXml({ root: { '@id': '1', name: 'Alice' } }); * // → Alice * * const xml = jsonToXmlString({ root: { item: ['a', 'b', 'c'] } }); */ import { XmlDocument } from '../parser/XmlNodes'; export type JsonValue = string | number | boolean | null | JsonObject | JsonValue[]; export interface JsonObject { [key: string]: JsonValue; } export interface JsonToXmlOptions { /** * Prefix that identifies attribute keys. Default: '@' * e.g. '@id' → id="..." */ attributePrefix?: string; /** * Key whose value becomes the text content of the element. Default: '_text' */ textKey?: string; /** * Root element name to wrap the document in when the input object has * multiple top-level keys. When the input has exactly one key, that key * becomes the root element regardless of this option. Default: 'root' */ rootName?: string; /** * XML version string in the declaration. Default: '1.0' */ xmlVersion?: string; /** * XML encoding string in the declaration. Default: 'UTF-8' */ xmlEncoding?: string; /** * Indentation spaces for serialization. Default: 2 */ indent?: number; } /** * Convert a JSON object into an XmlDocument. */ export declare function jsonToXml(json: JsonObject, options?: JsonToXmlOptions): XmlDocument; /** * Convert a JSON object directly to an XML string. */ export declare function jsonToXmlString(json: JsonObject, options?: JsonToXmlOptions): string; //# sourceMappingURL=JsonToXml.d.ts.map