跳到主要内容
uencoder

转换 XML to JSON and back

Translate 之间 XML 和 JSON 为 interoperability 具有遗留 APIs, preserving attributes, namespaces, 和 mixed 内容.

  1. 1

    XML 和 JSON 有不同 models: XML 有 attributes, namespaces, 和 mixed 内容; JSON 有仅 objects, arrays, 和 scalars. Conversion requires conventions 为 representing attributes (e.g. @attr) 和文本内容 (e.g. #文本).

  2. 2
    JSON 与 XML 互转器 →

    Paste XML 到 get JSON, 或 JSON 到 get XML. tool 我们 consistent 约定为 attributes 和文本 nodes, 和 handles namespaces 通过 prefixing.

  3. 3

    Use 链接到 转换 JSON→XML 具有 pretty-printing 和 proper 声明, 为 sending 到 XML-expecting APIs.

  4. 4
    XML 格式化器 →

    格式化 or minify XML independently — useful when the XML is valid but hard to read, or needs compression for transport.

常见问题

为什么 attributes look 不同在 JSON?
XML attributes 有否 direct JSON equivalent. Converters 通常 prefix 它们 (e.g. @id 为属性 id) 或 nest 它们在 特殊键. 约定 varies 通过 tool — 检查输出结构之前 consuming 它.
能够所有 XML 是 converted 到 JSON?
最多 XML 能够, 但 mixed 内容 (文本 interspersed 具有子 elements, like <p>Hello <b>world</b></p>) 是 awkward 在 JSON 和 requires 数组 conventions. Namespaces 和过程 instructions 可以 also 是 lost 或 represented 不同.

解决此任务的工作流

相关工具