raghu_3
raghu_3

Reputation: 1909

JSON Parsing error -Invalid Character at position 0

I am trying to parse do a GET with my click method

Using Windows.Data.Json;

private async void getJSON_click(object sender,RoutedEventArgs e)

{ 
   var client=new HttpClient();
   client.MaxResponseBufferSize=1024*1024;
   var response= await Client.GetAsync(new Uri(The URL here));
   var result = await response.Content.ReadAsStringAsync();

   var component=JsonArray.Parse(result);

}

The Following is error message - WINRT information :Invalid Character at position 0. Invalid JSON String.

This my JSON Data which i am trying to parse: {"X-YZ-12345/AB.CD" :{"PM1":"F","PM2":"47.12"}}

Any help highly appreciated.

Upvotes: 1

Views: 5346

Answers (1)

I4V
I4V

Reputation: 35363

It is not an array it an object. try JsonObject.

string result = @"{""X-YZ-12345/AB.CD"" :{""PM1"":""F"",""PM2"":""47.12""}}";
var jobj = JsonObject.Parse(result);

Upvotes: 4

Related Questions