Ankit  Shukla

Ankit Shukla

  • 1.3k
  • 618
  • 46.2k

JSON Array deserialization

Jan 23 2019 6:01 AM
Hello All,
 
My JSON array is this:
 

{"reqData":[{"cctns_ps_cd":2044028,"fir_srno":371,"reg_year":2018},{"cctns_ps_cd":2044048,"fir_srno":309,"reg_year":2018},{"cctns_ps_cd":2044001,"fir_srno":165,"reg_year":2018},{"cctns_ps_cd":2044069,"fir_srno":547,"reg_year":2018},{"cctns_ps_cd":2044040,"fir_srno":326,"reg_year":2018},{"cctns_ps_cd":2044071,"fir_srno":213,"reg_year":2018}]}

I am trying to deserialize it like this:
 
var empObj = JsonConvert.DeserializeObject<List<Employee>>(json1);
 
 But fails.
 
This code works when json format is like this:
 
string json1 = @"[
{'cctns_ps_cd':2044071,'fir_srno':207,'reg_year':2018},
{'cctns_ps_cd':2044033,'fir_srno':187,'reg_year':2018},
{'cctns_ps_cd':2044044,'fir_srno':174,'reg_year':2018},
{'cctns_ps_cd':2044022,'fir_srno':201,'reg_year':2018}]";
Please help. 
 

Answers (12)