Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Parse Json string with Html content

I use Json.net to parse json responce from web, but i have a problem if the json response contain html code.

For example:

string hj = @"{""data"": ""<a href=""www.google.com"">Google</a>""}";
JObject o1 = JObject.Parse(hj);

It raise a exception.

How can I parse the JSon response?

like image 447
user1986783 Avatar asked Mar 25 '26 03:03

user1986783


1 Answers

The JSON is invalid, so it can't be parsed. You have to escape the quotation marks inside the string:

string hj = @"{""data"": ""<a href=\""www.google.com\"">Google</a>""}";
like image 173
Guffa Avatar answered Mar 27 '26 18:03

Guffa



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!