3

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();

        }
    }
}
mjwills
  • 23,389
  • 6
  • 40
  • 63
Morteza Jangjoo
  • 1,780
  • 2
  • 13
  • 25

1 Answers1

4

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.

  • https://stackoverflow.com/questions/6620165/how-can-i-parse-json-with-c –  Jul 04 '18 at 12:50