- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我是 json 和 c# 的新手,我正在尝试从 api 收集一些数据。 json 数据的部分链接是:https://data.cityofchicago.org/api/views/*REMOVED*/rows.json?search=rahm&jsonp=?
而且给出的数据有点乱:
{
"meta" : {
"view" : {
"id" : "xzkq-xp2w",
"name" : "Current Employee Names, Salaries, and Position Titles",
"attribution" : "City of Chicago",
"attributionLink" : "http://www.cityofchicago.org",
"averageRating" : 0,
"category" : "Administration & Finance",
"createdAt" : 1317154735,
"description" : "This dataset is a listing of all current City of Chicago employees, complete with full names, departments, positions, and annual salaries. For hourly employees the annual salary is estimated. Data Owner: Human Resources. Frequency: Data is updated quarterly. Last Updated: April 19, 2012. For information on the positions and related salaries detailed in the budget as of January 1, 2012, visit the \"Budget - Positions and Salaries in 2012 Appropriation Ordinance\" dataset: http://bit.ly/twq5oO",
"displayType" : "table",
"downloadCount" : 4033,
"numberOfComments" : 0,
"oid" : 538938,
"publicationAppendEnabled" : false,
"publicationDate" : 1334860835,
"publicationGroup" : 241512,
"publicationStage" : "published",
"rowClass" : "",
"rowsUpdatedAt" : 1334860755,
"rowsUpdatedBy" : "scy9-9wg4",
"searchString" : "rahm",
"signed" : false,
"tableId" : 300029,
"totalTimesRated" : 0,
"viewCount" : 48059,
"viewLastModified" : 1334860836,
"viewType" : "tabular",
"columns" : [ {
"id" : -1,
"name" : "sid",
"dataTypeName" : "meta_data",
"fieldName" : "sid",
"position" : 0,
"renderTypeName" : "meta_data",
"format" : {
}
}, {
"id" : -1,
"name" : "id",
"dataTypeName" : "meta_data",
"fieldName" : "id",
"position" : 0,
"renderTypeName" : "meta_data",
"format" : {
}
}, {
"id" : -1,
"name" : "position",
"dataTypeName" : "meta_data",
"fieldName" : "position",
"position" : 0,
"renderTypeName" : "meta_data",
"format" : {
}
}, {
"id" : -1,
"name" : "created_at",
"dataTypeName" : "meta_data",
"fieldName" : "created_at",
"position" : 0,
"renderTypeName" : "meta_data",
"format" : {
}
}, {
"id" : -1,
"name" : "created_meta",
"dataTypeName" : "meta_data",
"fieldName" : "created_meta",
"position" : 0,
"renderTypeName" : "meta_data",
"format" : {
}
}, {
"id" : -1,
"name" : "updated_at",
"dataTypeName" : "meta_data",
"fieldName" : "updated_at",
"position" : 0,
"renderTypeName" : "meta_data",
"format" : {
}
}, {
"id" : -1,
"name" : "updated_meta",
"dataTypeName" : "meta_data",
"fieldName" : "updated_meta",
"position" : 0,
"renderTypeName" : "meta_data",
"format" : {
}
}, {
"id" : -1,
"name" : "meta",
"dataTypeName" : "meta_data",
"fieldName" : "meta",
"position" : 0,
"renderTypeName" : "meta_data",
"format" : {
}
}, {
"id" : 6676081,
"name" : "Name",
"dataTypeName" : "text",
"fieldName" : "name",
"position" : 1,
"renderTypeName" : "text",
"tableColumnId" : 1532233,
"width" : 148,
"cachedContents" : {
"non_null" : 32925,
"smallest" : "AARON, ELVIA J",
"null" : 0,
"largest" : "ZYSKOWSKI, DARIUSZ",
"top" : [ {
"count" : 20,
"item" : "ZYSKO, RICHARD"
}, {
"count" : 19,
"item" : "ZYSKOWSKI, DARIUSZ"
} ]
},
"format" : {
}
}, {
"id" : 6676082,
"name" : "Position Title",
"dataTypeName" : "text",
"fieldName" : "job_titles",
"position" : 2,
"renderTypeName" : "text",
"tableColumnId" : 1532235,
"width" : 220,
"cachedContents" : {
"non_null" : 32925,
"smallest" : "A/MGR COM SVC-ELECTIONS",
"null" : 0,
"largest" : "ZONING PLAN EXAMINER",
"top" : [ {
"count" : 20,
"item" : "POLICE OFFICER"
}, {
"count" : 19,
"item" : "FIREFIGHTER"
}, {
"count" : 18,
"item" : "MOTOR TRUCK DRIVER"
}, {
"count" : 17,
"item" : "SANITATION LABORER"
}, {
"count" : 16,
"item" : "FIREFIGHTER-EMT"
}, {
"count" : 15,
"item" : "POLICE OFFICER (ASSIGNED AS DETECTIVE)"
}, {
"count" : 14,
"item" : "SERGEANT"
}, {
"count" : 13,
"item" : "CROSSING GUARD"
}, {
"count" : 12,
"item" : "TRAFFIC CONTROL AIDE-HOURLY"
}, {
"count" : 11,
"item" : "POOL MOTOR TRUCK DRIVER"
}, {
"count" : 10,
"item" : "CONSTRUCTION LABORER"
}, {
"count" : 9,
"item" : "FIREFIGHTER/PARAMEDIC"
}, {
"count" : 8,
"item" : "LIBRARIAN I"
}, {
"count" : 7,
"item" : "OPERATING ENGINEER-GROUP C"
}, {
"count" : 6,
"item" : "PARAMEDIC"
}, {
"count" : 5,
"item" : "FRM OF MACHINISTS - AUTOMOTIVE"
}, {
"count" : 4,
"item" : "ELECTRICAL MECHANIC"
}, {
"count" : 3,
"item" : "SENIOR PUBLIC INFORMATION OFFICER"
}, {
"count" : 2,
"item" : "LEGAL SECRETARY"
}, {
"count" : 1,
"item" : "AIRPORT OPERATIONS SUPVSR I"
} ]
},
"format" : {
"align" : "left"
}
}, {
"id" : 6676083,
"name" : "Department",
"dataTypeName" : "text",
"fieldName" : "department",
"position" : 3,
"renderTypeName" : "text",
"tableColumnId" : 1532236,
"width" : 183,
"cachedContents" : {
"non_null" : 32925,
"smallest" : "ADMIN HEARNG",
"null" : 0,
"largest" : "WATER MGMNT",
"top" : [ {
"count" : 20,
"item" : "WATER MGMNT"
}, {
"count" : 19,
"item" : "POLICE"
}, {
"count" : 18,
"item" : "GENERAL SERVICES"
}, {
"count" : 17,
"item" : "FIRE"
}, {
"count" : 16,
"item" : "FAMILY & SUPPORT"
}, {
"count" : 15,
"item" : "STREETS & SAN"
}, {
"count" : 14,
"item" : "FINANCE"
}, {
"count" : 13,
"item" : "BUSINESS AFFAIRS"
}, {
"count" : 12,
"item" : "OEMC"
}, {
"count" : 11,
"item" : "TRANSPORTN"
}, {
"count" : 10,
"item" : "HEALTH"
}, {
"count" : 9,
"item" : "AVIATION"
}, {
"count" : 8,
"item" : "LAW"
}, {
"count" : 7,
"item" : "PUBLIC LIBRARY"
}, {
"count" : 6,
"item" : "ADMIN HEARNG"
}, {
"count" : 5,
"item" : "CULTURAL AFFAIRS"
}, {
"count" : 4,
"item" : "COMMUNITY DEVELOPMENT"
}, {
"count" : 3,
"item" : "BUILDINGS"
}, {
"count" : 2,
"item" : "CITY COUNCIL"
}, {
"count" : 1,
"item" : "CITY CLERK"
} ]
},
"format" : {
}
}, {
"id" : 6676084,
"name" : "Employee Annual Salary",
"dataTypeName" : "money",
"fieldName" : "employee_annual_salary",
"position" : 4,
"renderTypeName" : "money",
"tableColumnId" : 1532237,
"width" : 161,
"cachedContents" : {
"non_null" : 32925,
"smallest" : "0.96",
"sum" : "2475198578.40",
"null" : 0,
"average" : "75176.87405922551",
"largest" : "260004.00",
"top" : [ {
"count" : 20,
"item" : "75372.00"
}, {
"count" : 19,
"item" : "78012.00"
}, {
"count" : 18,
"item" : "80724.00"
}, {
"count" : 17,
"item" : "70408.00"
}, {
"count" : 16,
"item" : "68203.20"
}, {
"count" : 15,
"item" : "83706.00"
}, {
"count" : 14,
"item" : "73216.00"
}, {
"count" : 13,
"item" : "18886.40"
}, {
"count" : 12,
"item" : "84032.00"
}, {
"count" : 11,
"item" : "86840.00"
}, {
"count" : 10,
"item" : "61530.00"
}, {
"count" : 9,
"item" : "83982.00"
}, {
"count" : 8,
"item" : "99648.00"
}, {
"count" : 7,
"item" : "87324.00"
}, {
"count" : 6,
"item" : "62796.00"
}, {
"count" : 5,
"item" : "100048.00"
}, {
"count" : 4,
"item" : "62916.00"
}, {
"count" : 3,
"item" : "87372.00"
}, {
"count" : 2,
"item" : "84760.00"
}, {
"count" : 1,
"item" : "89772.80"
} ]
},
"format" : {
"precisionStyle" : "standard",
"noCommas" : "false",
"align" : "right"
}
} ],
"grants" : [ {
"inherited" : false,
"type" : "viewer",
"flags" : [ "public" ]
} ],
"metadata" : {
"custom_fields" : {
"Metadata" : {
"Last Updated Date via Automated Load" : "",
"Time Period" : "Last Updated April 19, 2012",
"Data Owner" : "Human Resources",
"Frequency" : "Data is updated quarterly"
}
},
"renderTypeConfig" : {
"visible" : {
"table" : true
}
},
"availableDisplayTypes" : [ "table", "fatrow", "page" ],
"rdfSubject" : "0",
"filterCondition" : {
"value" : "AND",
"children" : [ {
"value" : "OR",
"type" : "operator",
"metadata" : {
"includeAuto" : 15,
"tableColumnId" : {
"241512" : 1532236
},
"operator" : "EQUALS"
}
} ],
"type" : "operator",
"metadata" : {
"unifiedVersion" : 2,
"advanced" : true
}
},
"rowIdentifier" : "0",
"rdfClass" : ""
},
"owner" : {
"id" : "vi9p-p863",
"displayName" : "Eric Phillips",
"emailUnsubscribed" : false,
"privacyControl" : "login",
"profileLastModified" : 1333412533,
"roleName" : "administrator",
"screenName" : "Eric Phillips",
"rights" : [ "create_datasets", "edit_others_datasets", "edit_sdp", "edit_site_theme", "moderate_comments", "manage_users", "chown_datasets", "edit_nominations", "approve_nominations", "feature_items", "federations", "manage_stories", "manage_approval", "change_configurations", "view_domain", "view_others_datasets", "edit_pages", "create_pages" ]
},
"query" : {
},
"rights" : [ "read" ],
"tableAuthor" : {
"id" : "vi9p-p863",
"displayName" : "Eric Phillips",
"emailUnsubscribed" : false,
"privacyControl" : "login",
"profileLastModified" : 1333412533,
"roleName" : "administrator",
"screenName" : "Eric Phillips",
"rights" : [ "create_datasets", "edit_others_datasets", "edit_sdp", "edit_site_theme", "moderate_comments", "manage_users", "chown_datasets", "edit_nominations", "approve_nominations", "feature_items", "federations", "manage_stories", "manage_approval", "change_configurations", "view_domain", "view_others_datasets", "edit_pages", "create_pages" ]
},
"tags" : [ "personnel" ],
"flags" : [ "default" ]
}
},
"data" : [ [ 8172, "56A29995-E979-411D-BE47-27F48FD1A0A1", 8172, 1334860745, "386464", 1334860745, "386464", "{\n}", "EMANUEL, RAHM", "MAYOR", "MAYOR'S OFFICE", "216210.00" ]
]
}
现在我正在尝试获取特定人员的薪水,即“数据”列表最后一行中的 216210。
这就是我现在拥有的:
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (e.Error != null)
{
return;
}
List<Employee> emp = JsonConvert.DeserializeObject<List<Employee>>(e.Result);
this.lbTweets.ItemsSource = emp;
}
}
public class Employee
{
[JsonProperty("data")]
public string salary
{
get;
set;
}
}
我想我没有正确的 [JsonProperty("data")]
部分,单击按钮后出现此错误:
An unhandled exception of type 'Newtonsoft.Json.JsonReaderException' occurred in Newtonsoft.Json.dll
Additional information: Unexpected character encountered while parsing value: ?. Line 0, position 0.
有人可以帮忙吗?谢谢
编辑:不确定这是否有帮助,但我使用以下代码在 javascript 中对其进行了解析:
$.getJSON(this.query, function(response) {
var i, results;
results = [];
for (i = 0; i < response.data.length; i += 1) {
row = {
name: response.data[i][8],
salary: response.data[i][11]
}
results.push(row);
}
更新:在仅将链接设为 json 请求而非 jsonp 请求后,新的 json 不再包含任何额外字符。但我收到一个新错误:附加信息:无法将 JSON 对象反序列化为类型“System.Collections.Generic.List`1[WPJsonSample.Tweet]”。第 2 行,位置 11。
我已经使用 json2csharp 为我生成类,所以我有这个类:
public class RootObject
{
public Meta meta { get; set; } // removed this line because I only want the data
public List<List<object>> data { get; set; }
}
但是我仍然从上面得到那个错误,是不是我没有正确的数据类型:
List<RootObject> tweets = JsonConvert.DeserializeObject<List<RootObject>>(e.Result);
最佳答案
你真的需要使用 JSONP 吗? http://en.wikipedia.org/wiki/JSONP
这个 url 是否更适合获取和反序列化一个简单的 JSON 对象? https://data.cityofchicago.org/api/views/xzkq-xp2w/rows.json?search=rahm
通过使用 JSONP(对于每个示例的“ajax 跨域请求”),您最后需要一个回调函数: https://data.cityofchicago.org/api/views/xzkq-xp2w/rows.json?search=rahm&jsonp=callbackfunc(jquery的JSONP请求每次都会添加一个唯一的回调函数)。
关于c# - 在 Windows Phone c# 中解析 JSON,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10830071/
我开发了一个使用 mspn 服务的 windows phone 应用程序。它在 Windows 手机模拟器上运行良好。现在我想在 Windows Phone 设备中测试它。我有一个 Windows P
我正在考虑针对 Windows Phone 7 进行开发。为了测试我的应用程序,我需要能够模拟电话调用。在模拟器中可以吗? 最佳答案 不,不可能模拟您的应用程序被接收到的电话中断。还宣布为 the R
我看到 Windows Phone 8 支持 Windows Phone 7 应用程序。我在 Windows Phone 7 上开发了一些应用程序,我想在 Windows Phone 8 模拟器上运行
我正在Windows 8上使用Visual Studio2013。我有三个Windows Phone设备,lumia 620、920、1320,这些都是开发人员解锁的设备。 620设备已安装Windo
非常直接的问题。我的公司开发了一个 windows phone 7 应用程序,并一直在 windows phone 7 设备上对其进行测试。我们能否安全地假设同一个应用程序将向后兼容并在 Window
标题几乎概括了它。我已经编写了一个 Windows Phone 7 应用程序,现在我想将它部署到 Windows Phone 8 设备 (HTC Windows Phone 8X)。我已经注册并解锁了
我一直在开发 Windows Phone 8 应用程序,现在我想将其更改为 Windows Phone 8.1。我该怎么做? 是否应该创建一个新的 Windows Phone 8.1 应用并将所有现有
我有一个针对 Windows Phone 8 的应用程序。现在我想使用 this compression library其中指出: Supported Platforms: .NET Framewor
有什么区别Windows Phone 7.1 (NoDo) 和 Windows Phone 7.5 (芒果) ? 我已经为 Mango 安装了 SDK,但是当我尝试创建一个项目时,它显示为 7.1 版
我最近更新了我的 Visual Studio 2013,现在它允许开发 Windows Phone 8.1 应用程序。 但是现在,当我创建一个 Windows Phone 项目时,它是针对 WP 8.
我最近购买了 Lumia 630 双 SIM 卡,并一直在尝试注册我的手机以进行开发,但一直收到此错误“无法连接到手机。请确保通过 USB 传输服务的 Windows Phone IP 正在运行”。
我正在尝试使用 documentation from MSDN 在我现有的 Windows Phone OS 7.1 应用程序中支持新的 Windows Phone 磁贴功能。 .但是,我似乎无法通过
我在搜索如何启动Windows Phone 10模拟器时迷路了。 我已经做了: 我下载并安装了仿真器镜像(我知道flash.vhd文件的位置) 我正在运行Windows 8.1 x64专业版。 Hyp
我想制作像图片一样的动态磁贴。我该怎么做? 最佳答案 上面创建的图 block 很可能是在服务器端创建的。据说 Windows Phone 7.1 和 Windows Phone 8 之间发生了很多变
我刚刚将它安装在我的 Windows 8 上。它不是在 VM 上运行,而是在带有 bootcamp 的 macbook 上运行。 当我尝试模拟我的应用程序时,出现第一个错误: 但是后来我单击“重试”并
Microsoft 刚刚发布了结合了 Windows 8.1 和 Windows Phone 8.1 的 Windows App 8.1,因此您可以创建一个通用的应用程序。但是,将 Microsoft
是否有可用于WP7的日历控件(不是日期选择器和时间选择器)? 最佳答案 我还在CodePlex上启动了新项目。我刚刚研究了日历控件的Alpha版本。 http://wpcontrols.codeple
我在XAML中有一个文本框: .cs文件声明了以下事件: private void blah_OnKeyDown(object sender, KeyEventArgs e) {
关闭。这个问题需要更多focused .它目前不接受答案。 想改进这个问题吗? 更新问题,使其只关注一个问题 editing this post . 关闭 8 年前。 Improve this qu
我正在为Windows Phone 7创建一个多人游戏。如何调试模拟器的多个实例以便对其进行调试? 最佳答案 实际上,您可以同时运行Windows Phone 7模拟器的多个实例,甚至可以同时调试它们
我是一名优秀的程序员,十分优秀!