简体   繁体   中英

Passing HTML using JSON

I'm passing Data using JSON to iPhone and iPad. One Field of Data is 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.

Any good way to do this?

Any JSON to HTML Cleaning Functions? Encoding?

(There must be something better than manually removing )

Thanks

It is HTML, it is just JSON encoded. Use a standard JSON parser and the string you get back will have the escape characters handled for you…

… or are you trying to write your own JSON parser? (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)).

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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