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>Hel开发者_StackOverflow中文版lo</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)).
The service that sends the JSON Block should escape all back slashes with another backslash.
精彩评论