如果这是字符串{" ValidateUser":[{"用户名":"管理员","传递":&# 34;联系"比如何获取传递值,因为在pair.value中我只获取用户名。
JObject o = JObject.Parse(user_db);
foreach (var i in o["ValidateUser"])
{
JObject parsed = JObject.Parse("" + o["ValidateUser"][j]);
foreach (var pair in parsed)
{
if (string.Equals(user_name.Text, pair.Value))
{
if(string.Equals(password.Text,pair.Value))
{
MessageBox.Show("Success");
}
}
}
j++;
}
答案 0 :(得分:1)
Use Below code to solve your problem
string source = "{ "ValidateUser": [ { "username": "Admin", "pass":"Admin" } ]}";
dynamic data = JObject.Parse(source);
Console.WriteLine(data.username);
Console.WriteLine(data.pass);
所以如果使用下面的代码,希望能帮到你。
JObject o = JObject.Parse(user_db);
foreach (var i in o["ValidateUser"])
{
dynamic data = JObject.Parse("" + o["ValidateUser"][j]);
foreach (var pair in parsed)
{
if (string.Equals(user_name.Text, data.username))
{
if(string.Equals(password.Text,data.pass))
{
MessageBox.Show("Success");
}
}
}
j++;
}