这不起作用(文件存在,读取正常,然后没有任何循环触发)而且我不知道为什么..
if (File.Exists("my.json"))
{
var response = System.IO.File.ReadAllText("my.json");
var domains = JsonConvert.DeserializeObject<List<jsonRead>>(response);
foreach (jsonRead domain in domains)
{
MessageBox.Show(domain.Password);
var folders = JsonConvert.DeserializeObject<List<jsonReadDeep>>(domain.Folders);
foreach (jsonReadDeep folder in folders)
{
MessageBox.Show(folder.localServer);
}
}
}
班级
class jsonRead
{
public string Folders;
public string Name;
public string User;
public string Password;
public string Url;
}
class jsonReadDeep
{
public string localFolder;
public string serverFolder;
}
json
[
{
"Folders": [
{
"localFolder": "C:\\test",
"serverFolder": "Default/"
}
],
"Name": "hi",
"User": "there",
"Password": "secret",
"Url": "https://mydomain.com"
}
]