Passing HTML Using JSON

I transfer data using JSON to iPhone and iPad. One data field is HTML.

The problem is coding.

Here is what I will return:

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

They’re killing me. \ n does not help.

Any good way to do this?

Any JSON cleanup features for HTML? Coding?

(there must be something better than manual)

thanks

+4
source share
2 answers

This is HTML, this is just JSON encoding. Use a standard JSON parser, and the string you get will have control characters processed for you ...

... or are you trying to write your own JSON parser? (This may not be a good idea, but if you really want to invent the wheel, the specification is at http://json.org (and the ECMA-262 specification will probably help you in grammar)).

+3
source

A service that sends a JSON block should flush all backslashes with a different backslash.

0
source

Source: https://habr.com/ru/post/1312896/


All Articles