本文整理汇总了C#中Newtonsoft.Json.JsonReader.ReadToProperty方法的典型用法代码示例。如果您正苦于以下问题:C# JsonReader.ReadToProperty方法的具体用法?C# JsonReader.ReadToProperty怎么用?C# JsonReader.ReadToProperty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Newtonsoft.Json.JsonReader
的用法示例。
在下文中一共展示了JsonReader.ReadToProperty方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MoveNext
public override bool MoveNext()
{
if (IsDisposed) throw new ObjectDisposedException(null);
if (_reader == null)
{
var wc = new WebClient();
//var json = wc.DownloadString("http://data.baltimorecity.gov/api/views/ijfz-2v3c/rows.json");
//var json = wc.DownloadString("file:///C:/Users/PTying/Documents/GitHub/civilsalary/civilsalary.datasync/usa/md/baltimorecity/rows.json");
var uri = new Uri((new FileInfo("..\\..\\..\\civilsalary.datasync\\usa\\md\\baltimorecity\\rows.json")).FullName);
var json = wc.DownloadString(uri);
_reader = new JsonTextReader(new StringReader(json));
_reader.ReadToProperty("meta", 1);
_reader.ReadToProperty("view", 3);
_reader.Read(); //start view object...
_view = JObject.Load(_reader).AsDynamic();
_reader.ReadToProperty("data", 1);
_reader.Read(); //step in to data
}
if (_reader.Read() && _reader.Depth == DataDepth)
{
var currentValues = JArray.Load(_reader);
_current = new EmployeeData()
{
DepartmentName = ((string)currentValues[ColumnIndex("agency")]).Trim(),
DepartmentKey = ((string)currentValues[ColumnIndex("agency")]).Trim().ToUrlValue(),
Row = new EmployeeRow()
{
GovernmentKey = _government,
Name = ((string)currentValues[ColumnIndex("name")]).Trim().Trim(','),
EmployeeId = ((string)currentValues[ColumnIndex("id")]).Trim(),
Position = ((string)currentValues[ColumnIndex("jobtitle")]).Trim(),
Salary = double.Parse((string)currentValues[ColumnIndex("annualsalary")], NumberStyles.AllowCurrencySymbol
| NumberStyles.AllowDecimalPoint
| NumberStyles.AllowLeadingSign
| NumberStyles.AllowParentheses
| NumberStyles.AllowThousands),
GrossPay = double.Parse((string)currentValues[ColumnIndex("grosspay")], NumberStyles.AllowCurrencySymbol
| NumberStyles.AllowDecimalPoint
| NumberStyles.AllowLeadingSign
| NumberStyles.AllowParentheses
| NumberStyles.AllowThousands),
HireDate = (string)currentValues[ColumnIndex("hiredate")] == null ? (DateTime?)null : DateTime.Parse((string)currentValues[ColumnIndex("hiredate")])
}
};
return true;
}
else
{
return false;
}
}