转换 XML to JSON and back
Translate 之间 XML 和 JSON 为 interoperability 具有遗留 APIs, preserving attributes, namespaces, 和 mixed 内容.
- 1
XML 和 JSON 有不同 models: XML 有 attributes, namespaces, 和 mixed 内容; JSON 有仅 objects, arrays, 和 scalars. Conversion requires conventions 为 representing attributes (e.g. @attr) 和文本内容 (e.g. #文本).
- 2 JSON 与 XML 互转器 →
Paste XML 到 get JSON, 或 JSON 到 get XML. tool 我们 consistent 约定为 attributes 和文本 nodes, 和 handles namespaces 通过 prefixing.
- 3
- 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 不同.
解决此任务的工作流
JSON 转 XML
将 JSON 文档转换为 XML 形式,用于仅接受 XML 的遗留系统集成。 管道
JSON 转格式化 XML
将 JSON 文档转换为 XML 并格式化输出以提升可读性。 管道
Plist 转 JSON 再转 XML
将 Apple plist 转为 JSON 再转 XML。 管道
格式化原始 XML 文档
格式化压缩或未格式化的 XML 文档,便于人工审阅。 管道
XML 转 JSON 再转 CSV
通过 JSON 中间表示将 XML 文档扁平化为 CSV,以便电子表格消费。 管道
XML 转 JSON 再转 YAML
将 XML 转为 JSON 再转为 YAML。 管道