本文整理匯總了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;
}
}