4

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

2 Answers 2

3

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)).

Sign up to request clarification or add additional context in comments.

1 Comment

Hi David, Thanks. We are in fact already using the Google JSON Framework...So I thought It should handle the escaping automatically. Seems not the case. Is there some framework Flag I am missing? Some specific 'CleanJSON' call? thx
0

The service that sends the JSON Block should escape all back slashes with another backslash.

2 Comments

That would change alt\" into alt=\\" so the data would include a ` character, then there would be a "` character which (as it wouldn't be escaped any longer) would terminate the string, so the next character would invalidate the JSON.
Yeah - escaping needed for the wire. Just not after landing on client. But thanks

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.