Note that there are some explanatory texts on larger screens.

plurals
  1. POCannot deserialize the current JSON object
    text
    copied!<p>Im getting this exception. I don't understand what should i do. I have googled a lot but found nothing.</p> <blockquote> <p>Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Collections.ObjectModel.ObservableCollection`1[LU.FacebookStalker.StoreApp.ViewModel.PageLike]' because the type requires a JSON array (e.g. [1,2,3]) to deserialize correctly.</p> <p>To fix this error either change the JSON to a JSON array (e.g. [1,2,3]) or change the deserialized type so that it is a normal .NET type (e.g. not a primitive type like integer, not a collection type like an array or List) that can be deserialized from a JSON object. JsonObjectAttribute can also be added to the type to force it to deserialize from a JSON object.</p> </blockquote> <p>This is my class:</p> <pre><code> public class PageLike { public string Id { get; set; } public string Name { get; set; } public string count { get; set; } public string photoUrl { get; set; } } public class Hangout { public string Id { get; set; } public string Name { get; set; } public string photoUrl { get; set; } public int count { get; set; } } public class Interaction { public string Id { get; set; } public string Name { get; set; } public string photoUrl { get; set; } public int count { get; set; } } public class Place { public object Id { get; set; } public string Name { get; set; } public string photoUrl { get; set; } public int count { get; set; } } public class HomeSummaryResult { public List&lt;Hangout&gt; hangouts { get; set; } public List&lt;Interaction&gt; interactions { get; set; } public List&lt;PageLike&gt; likes { get; set; } public List&lt;Place&gt; places { get; set; } } public class RootObject { public HomeSummaryResult HomeSummaryResult { get; set; } } </code></pre> <p>I am calling service like this:</p> <pre><code>HttpClient client = new HttpClient(); string url = string.Format(""); HttpResponseMessage response = await client.GetAsync(url); dynamic likesResult= await response.Content.ReadAsStringAsync(); var x = (JsonConvert.DeserializeObject&lt;IDictionary&lt;string, object&gt;&gt;(likesResult.ToString()))["HomeSummaryResult"]; likesList = JsonConvert.DeserializeObject&lt;ObservableCollection&lt;PageLike&gt;&gt;(x.ToString()); </code></pre> <p>And my JSON is:</p> <pre><code>{ "HomeSummaryResult": { "hangouts": [ { "Id": "112", "Name": "Mohsin", "photoUrl": "graph.facebook.com\/112\/picture", "count": 12 }, { "Id": "103", "Name": "Khan", "photoUrl": "graph.facebook.com\/103\/picture", "count": 11 } ], "interactions": [ { "Id": "724", "Name": "Jawad Shareef", "photoUrl": "graph.facebook.com\/724\/picture", "count": 482 }, { "Id": "583", "Name": "Ahsan Aziz Abbasi", "photoUrl": "graph.facebook.com\/583\/picture", "count": 228 } ], "likes": [ { "Id": "122", "Name": "Community", "photoUrl": "graph.facebook.com\/122\/picture", "count": 324 }, { "Id": "110", "Name": "Musician\/band", "photoUrl": "graph.facebook.com\/110\/picture", "count": 119 } ], "places": [ { "Id": null, "Name": "Local business", "photoUrl": "graph.facebook.com\/\/picture", "count": 69 }, { "Id": null, "Name": "City", "photoUrl": "graph.facebook.com\/\/picture", "count": 43 } ] } } </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload