K
K
kmx2014-09-24 19:07:18
Windows phone
kmx, 2014-09-24 19:07:18

How to escape special characters from the received json array in C#?

What is the correct way to escape special characters from the text array (json) received from the server in C# so that the application does not crash when the parsed text is displayed on the screen?
If the text in JSon contains " ", etc. then the application crashes. So far, I have to cut out all the special symbols, but this solution does not suit me.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
G
gleb_kudr, 2014-09-24
@kmx

csharpindepth.com/Articles/General/Strings.aspx this should help.
In short, escape strings with the @ sign like this. It escapes all characters except double quotes. If there are significant double quotes in the text, then they need to be changed to two double quotes.

var text= @"Hello, ""mister""";
//Результат

hello mister

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question