我遇到了Json.NET库及其DeserializeObject方法.文档对于这里可能发生的事情并不十分清楚,所以如果有人能够解释如何将JSON反序列化为User对象列表,我将不胜感激.
我正在尝试反序列化这个JSON
[
{"userid":"0",
"listid":1,
"lastname":"Mann",
"inplace":true,
"xpos":428,
"ypos":111
},
{"userid":"1",
"listid":1,
"lastname":"Parker",
"inplace":true,
"xpos":334,
"ypos":154
},
{"userid":"2",
"listid":1,
"lastname":"Terry",
"inplace":true,
"xpos":513,
"ypos":160
}
]
Run Code Online (Sandbox Code Playgroud)
进入用户对象
[JsonObject(MemberSerialization.OptIn)]
public class User
{
[JsonProperty(PropertyName = "userid")]
public string userid { get; set; }
[JsonProperty(PropertyName = "listid")]
public int listid { get; set; }
[JsonProperty(PropertyName = "lastname")]
public string lastname { get; set; }
[JsonProperty(PropertyName = "inplace")]
public bool inplace { get; set; }
[JsonProperty(PropertyName = "xpos")]
public int xpos { get; set; …Run Code Online (Sandbox Code Playgroud)