本文整理汇总了C#中Newtonsoft.Json.JsonTextReader.ReadStringArray方法的典型用法代码示例。如果您正苦于以下问题:C# JsonTextReader.ReadStringArray方法的具体用法?C# JsonTextReader.ReadStringArray怎么用?C# JsonTextReader.ReadStringArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.JsonTextReader
的用法示例。
在下文中一共展示了JsonTextReader.ReadStringArray方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Deserialize
public static ServerInformation[] Deserialize(Stream stream) {
var reader = new JsonTextReader(new StreamReader(stream));
var response = new List<ServerInformation>(1200);
var currentProperty = string.Empty;
reader.MatchNext(JsonToken.StartArray);
while (reader.IsMatchNext(JsonToken.StartObject)) {
var entry = new ServerInformation();
while (reader.Until(JsonToken.EndObject)) {
switch (reader.TokenType) {
case JsonToken.PropertyName:
currentProperty = reader.Value.ToString();
break;
case JsonToken.String:
switch (currentProperty) {
case "ip":
entry.Ip = reader.Value.ToString();
break;
case "name":
entry.Name = reader.Value.ToString();
break;
case "track":
entry.TrackId = reader.Value.ToString();
break;
}
break;
case JsonToken.Integer:
switch (currentProperty) {
case "port":
entry.Port = int.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture);
break;
case "cport":
entry.PortC = int.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture);
break;
case "tport":
entry.PortT = int.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture);
break;
case "clients":
entry.Clients = int.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture);
break;
case "maxclients":
entry.Capacity = int.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture);
break;
case "timeofday":
entry.Time = int.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture);
break;
case "session":
entry.Session = int.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture);
break;
case "timeleft":
entry.TimeLeft = long.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture);
break;
case "timestamp":
entry.Timestamp = long.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture);
break;
case "lastupdate":
entry.LastUpdate = long.Parse(reader.Value.ToString(), CultureInfo.InvariantCulture);
break;
}
break;
case JsonToken.Boolean:
switch (currentProperty) {
case "pass":
entry.Password = bool.Parse(reader.Value.ToString());
break;
case "pickup":
entry.PickUp = bool.Parse(reader.Value.ToString());
break;
case "l":
entry.L = bool.Parse(reader.Value.ToString());
break;
}
break;
case JsonToken.StartArray:
switch (currentProperty) {
case "cars":
entry.CarIds = reader.ReadStringArray(1);
break;
case "sessiontypes":
entry.SessionTypes = reader.ReadIntArray(1);
break;
case "durations":
entry.Durations = reader.ReadLongArray(1);
break;
case "country":
entry.Country = reader.ReadStringArray(2);
break;
default:
while (reader.Until(JsonToken.EndArray)) { }
break;
}
break;
default:
//.........这里部分代码省略.........