簡體   English   中英

數組反序列化不支持CandidateResume'類

[英]CandidateResume' class is not supported for deserialization of an array

我正在嘗試以這種方式在反序列化數組下面,但是我遇到了這個錯誤。

JavaScriptSerializer jsSerializer = new JavaScriptSerializer();
var myobj = jsSerializer.Deserialize<CandidateResume[]>(json);

這是我的json文件

[
   [
      {
         "name":"Riaz Kabir",
         "url":"https://recruit.theladders.com/resumeviewer?jobseekerId=01-sid-BDLBKUPMIL6HGZ22MOAJJIWYGE",
         "summary":"ASP.NET MVC Developer Hewlett-Packard (HP) (1/2013-Present) Location: Schenectady, NY Compensation: $50k+ Previous Titles/Companies: 2016 ►",
         "role":"ASP.NET MVC Developer at Hewlett-Packard (HP)",
         "compensation":"$50k+",
         "education":"BS, Computer Science and Engineering, Asian University of Bangladesh",
         "expertise":"Databases , IT Consulting , Software Development , Front End Development",
         "years":"Less than 5",
         "relocation":"Schenectady, NY Within 1000 miles of 12305 Would need to relocate here",
         "resume":"0M8R4KGxGuEAAAAAAAAAAAAAAAAAAAAAP",
         "resumeExtension":"doc",
         "resumeMimeType":"application/msword"
      }
   ]
]

貝婁我的候選人簡歷課

public class CandidateResume
        {

            public string name { get; set; }
            public string url { get; set; }
            public string summary { get; set; }
            public string role { get; set; }
            public string compensation { get; set; }
            public string education { get; set; }
            public string expertise { get; set; }
            public string years { get; set; }
            public string relocation { get; set; }
            public string resume { get; set; }
            public string resumeExtension { get; set; }
            public string resumeMimeType { get; set; }

        }

錯誤消息:CandidateResume'不支持反序列化數組。

您的JSON是列表的列表。 考慮一下CandidateResume is not supported for deserialization of an array.的錯誤CandidateResume is not supported for deserialization of an array. 它試圖將數組反序列化為CandidateResume對象。

而是嘗試:

var myobj = jsSerializer.Deserialize<List<List<CandidateResume>>>(json);

或者將您的JSON更改為不是列表列表。

在json中,您有額外的'['和']'。 只需刪除它們。 或者,如果無法接受,您可以嘗試

var myobj = jsSerializer.Deserialize<CandidateResume[][]>(json);

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM