c# - Unable to convert string to JSON object -


below json string

{   "resources": {     "resource": [       {         "resourceid": "d513e96f-ea6c-e511-8133-000d3a0044f4",         "mspslogin": "richa.dinesh.parkar",         "email": "richa.dinesh.parkar@accenture.com"       },       {         "resourceid": "d513e96f-ea6c-e511-8133-000d3a0044f4",         "mspslogin": "harshal.arun.vadnere",         "email ": "harshal.arun.vadnere@accenture.com"       }     ]   },     "createdon":"2016-07-18t12:51:14.23z",                              "createdbyapp":"ad"                            } 

my class in models:

public class resource    {     public string resourceid { get; set; }     public string mspslogin { get; set; }     public string email { get; set; }  }  public class resources {     public ilist<resource> resource { get; set; } }  public class example {     public resources resources { get; set; }     public datetime createdon { get; set; }     public string createdbyapp { get; set; } } 

i use json.net, want convert string below json object.

example example = jsonconvert.deserializeobject<example>(jsonstr); 

but error:

an unhandled exception of type 'newtonsoft.json.jsonserializationexception' occurred in newtonsoft.json.dll

additional information: cannot deserialize current json object (e.g. {"name":"value"}) type 'system.collections.generic.list`1[mywizard_msps_integration.example]' because type requires json array (e.g. [1,2,3]) deserialize correctly.

try changing ilist<resource> ienumerable<resource> or resource[], think json.net cannot initialize ilist. not supported feature.


Comments

Popular posts from this blog

php - How to add and update images or image url in Volusion using Volusion API -

javascript - jQuery UI Splitter/Resizable for unlimited amount of columns -

javascript - IE9 error '$'is not defined -