我想反序列化JSON字符串,但不知何故,我沒有得到正確的值:( 這是輸入JSON字符串反序列化JSON陣列
{
"files":[
{"path":"/c/asd/input.txt","size":13},
{"path":"/c/asd/input.txt","size":136},
{"path":"/c/asd/input.txt","size":483},
{"path":"/c/asd/input.txt","size":136}
],
"md5sum":"bbd88df7b2d8c95f922ebf0d718b5687"
}
創建一個類爲它
public class Files
{
public string path { get; set; }
public int size { get; set; }
}
public class myObject
{
public List<Files> files { get; set; }
public string md5sum { get; set; }
}
,並試圖使用JavaScriptSerializer:
var jss = new JavaScriptSerializer();
List<myObject> obj = s.Deserialize<List<myObject>>(File.ReadAllText(json));
我在做什麼錯OBJ計數?零。我只需要使用路徑值。