将 xml 放入 json 的最佳方法是什么?
What is the best way to put xml inside json?
你会用...
选项 1)
使用包含 xml 的字段创建对象。
使用 json 库将对象转换为 json 并让库进行转义。
选项 2)
Base64 编码 xml 并把 base64 编码的字符串放入 json.
选项 3)
还有别的吗?
Create object with field which contains xml. Transform object to json using json library and let the library do the escaping.
是的。这就是您创建 JSON 的方式。 (另一种方法是将字符串混在一起,这很容易出错)。
Base64 encode xml and put base64 encoded string inside json.
没有。 XML 只是文本。 Base64编码没有意义。
你会用...
选项 1)
使用包含 xml 的字段创建对象。 使用 json 库将对象转换为 json 并让库进行转义。
选项 2)
Base64 编码 xml 并把 base64 编码的字符串放入 json.
选项 3)
还有别的吗?
Create object with field which contains xml. Transform object to json using json library and let the library do the escaping.
是的。这就是您创建 JSON 的方式。 (另一种方法是将字符串混在一起,这很容易出错)。
Base64 encode xml and put base64 encoded string inside json.
没有。 XML 只是文本。 Base64编码没有意义。