简体   繁体   English

使用JSON传递HTML

[英]Passing HTML using JSON

I'm passing Data using JSON to iPhone and iPad. 我正在使用JSON将数据传递给iPhone和iPad。 One Field of Data is HTML. 一个数据领域是HTML。

The problem is the encoding. 问题是编码。

Here's what I get back: 这是我得到的回报:

> "GadgetHTML": "<strong>Hello</strong>
> from Catworld<br />\n<img alt=\"\"
> src=\"http://www.iconarchive.com/icons/fasticon/ifunny/128/dog-icon.png\"
> />",

The \\ are killing me. \\正在杀了我。 The \\n does not help. \\ n没有帮助。

Any good way to do this? 有什么好办法吗?

Any JSON to HTML Cleaning Functions? 任何JSON到HTML清理功能? Encoding? 编码?

(There must be something better than manually removing ) (必须有比手动删除更好的东西)

Thanks 谢谢

It is HTML, it is just JSON encoded. 它是HTML,它只是JSON编码。 Use a standard JSON parser and the string you get back will have the escape characters handled for you… 使用标准的JSON解析器,你得到的字符串将为你处理转义字符...

… or are you trying to write your own JSON parser? ...或者您是否正在尝试编写自己的JSON解析器? (Probably not a good idea, but if you really want to reinvent the wheel then the spec is at http://json.org (and the ECMA-262 specification would probably help you for the grammar)). (可能不是一个好主意,但如果你真的想要重新发明轮子那么规格是在http://json.org (ECMA-262规范可能会帮助你学习语法))。

发送JSON块的服务应该使用另一个反斜杠转义所有反斜杠。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM