我有来自服务器的多个学生姓名的响应
{"ENVELOPE":{"STUDENTLIST":{"STUDENT":["John","HHH"]}}}
或单个学生姓名
{"ENVELOPE":{"STUDENTLIST":{"STUDENT":"John"}}}
如果有错误
{"RESPONSE":{"LINEERROR":"Could not find Students"}}
从这些回复中,如果没有错误,我想要学生姓名数组 else string with error ie string[] names = {"John","HHH"} or string[] names = {"John"} else string error = "Could not find学生”;
我试过
JObject jObj = JObject.Parse(responseFromServer);
var msgProperty = jObj.Property("ENVELOPE");
var respProperty = jObj.Property("RESPONSE");
//check if property exists
if (msgProperty != null)
{
var mag = msgProperty.Value;
Console.WriteLine("has Student : " + mag);
/*
need logic here :/ */
}
else if (respProperty != null)
{
Console.WriteLine("no Students");
}
else
{
Console.WriteLine("Error while getting students");
}
希望你得到这个..
繁华开满天机
相关分类