static void Main(string[] args) { JsonConvertTest.DoTest(); JsonSerializerTest.DoTest(); JObjectTest.DoTest(); Console.ReadLine(); }
static void Main(string[] args) { DataContractJsonSerializerTest.DoTestWithSerialization(); JsonConvertTest.DoTestWithSerialization(); JsonConvertTest.DoTest(); JsonSerializerTest.DoTestWithSerialization(); JsonSerializerTest.DoTest(); JObjectTest.DoTest(); Console.ReadLine(); }
static async void MakeRequest() { var client = new HttpClient(); var queryString = HttpUtility.ParseQueryString(string.Empty); // Request headers client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "xxxxxx"); string imageFilePath = "Newhire-page-001.jpg"; // Request parameters queryString["mode"] = "Printed"; var uri = "https://westus.api.cognitive.microsoft.com/vision/v2.0/recognizeText/?mode=Handwritten"; //var uri = "https://westus.api.cognitive.microsoft.com/vision/v2.0/textOperations/75b89c16-64a0-42a3-a6a0-1a25c57b2399"; HttpResponseMessage response; // Request body //byte[] byteData = Encoding.UTF8.GetBytes("{body}"); byte[] byteData = GetImageAsByteArray(imageFilePath); using (var content = new ByteArrayContent(byteData)) { content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); response = await client.PostAsync(uri, content); } IEnumerable <string> r = response.Headers.GetValues("Operation-Location"); string textOperation = r.First(); response = await client.GetAsync(textOperation); string contentString = await response.Content.ReadAsStringAsync(); JObjectTest j = new JObjectTest(); // Display the JSON response. Console.WriteLine("\nResponse:\n\n{0}\n", j.JParse(JToken.Parse(contentString).ToString())); //JObjectTest j = new JObjectTest(); //j.JParse("hello"); }