Conversion of JSON from unicode to original format

772 Views Asked by At

I have a JSON string result(in persian language) from a webservive.

But the results from the web service are as this:

"\u0622\u062f\u0631\u0633 \u0627\u06cc\u0645\u06cc\u0644"

While the original text is as follows:

عملیات انجام شد

how to Conversion from unicode to original format C#

this is my code

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://webserver.com/");

request.Method = "GET";
request.ContentLength = 0;
request.Credentials = CredentialCache.DefaultCredentials;
request.ContentType = "application/xml";
request.Accept = "application/xml";

using (HttpWebResponse response = (HttpWebResponse)request.GetResponse())
{
    using (Stream receiveStream = response.GetResponseStream())
    {
        using (StreamReader readStream = new StreamReader(receiveStream, Encoding.UTF8))
        {
            string strContent = readStream.ReadToEnd();

        }
    }
}
1

There are 1 best solutions below

1
AudioBubble On BEST ANSWER

That looks like JSON. You would need parse it.

To confirm it, you could take the output and run it through an online decoder for example http://json.parser.online.fr/

{ "a": "\u0622\u062f\u0631\u0633 \u0627\u06cc\u0645\u06cc\u0644" }

Result is enter image description here

So to parse that in C#

string strContent = readStream.ReadToEnd(); 

dynamic stuff = JsonConvert.DeserializeObject(strContent);

You should be able to find out what structure is being returned by the web service - usually this is documented. Not much point creating a web service unless you tell people how to use it.