我需要从JSON字符串中提取值,以便我可以比较它们.我只需要验证它们是否有序(升序/降序).我打算检查第一个和第二个"选择"并进行比较.我没有更高级的东西.
编辑/更新:我如何在这种类型的查询中使用通配符(*)来跳过每个段?
string one = (string)o[this.Context[*WILDCARD*]["cid1"]].ToString();
/* this works, but has too many []
string one = (string)o[this.Context["partner"]]
[this.Context["campaign"]]
[this.Context["segment1"]]
[this.Context["segment2"]]
[this.Context["qid2"]]
["community"]
[this.Context["cid1"]].ToString();
*/
{
"partner": {
"campaign": {
"round1": {
"round2": {
"def123": {
"community": {
"choicec": 28
},
"user": {
"choice": "choicec",
"writeDateUTC": "2015-06-15T17:21:59Z"
}
}
},
"abc321": {
"community": {
"choicec": 33
},
"user": {
"choice": "choicec",
"writeDateUTC": "2015-06-15T17:21:59Z"
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud) 我使用它来设置表格的顶行(标题),但是我如何为最后一行做同样的事情呢?
更新:我在表上使用AngularJS ng-repeat,而中间行仅使用了针对最后一行的样式.
th:first-child {
border-top-left-radius: 15px;
}
th:last-child {
border-top-right-radius: 15px;
}
Run Code Online (Sandbox Code Playgroud) 我正在尝试找到一种方法来获取XmlNodeList并将其反序列化。
我将需要将XmlNodeList obj转换为序列化程序可以使用的对象,以进行反序列化。
有什么建议吗?
string fileLoc = @"File.xml";
XmlDocument xdoc = new XmlDocument();
xdoc.Load(fileLoc);
XmlNodeList ndlist = xdoc.SelectNodes("//DConfig/ConfigValue/UrlListValues/UrlInfo");
UrlListValues myObject;
XmlSerializer mySerializer = new XmlSerializer(typeof(UrlListValues));
FileStream myFileStream = new FileStream(fileLoc, FileMode.Open);
// *** This is where the problem starts. Cannot cast as UrlListValues
myObject = (UrlListValues)mySerializer.Deserialize(myFileStream);
foreach (UrlInfo xn in myObject)
{
// Do stuff
}
Run Code Online (Sandbox Code Playgroud)