假设我有一个存储在名为'test'的RethinkDB表中的JSON(示例 - 可以在apple itunes rss feed中找到的实例):
{
"feed": {
"entry": [
{
"title": {
"label": "Some super duper app"
},
"summary": {
"label": "Bla bla bla..."
}
},
{
"title": {
"label": "Another awsome app"
},
"summary": {
"label": "Lorem ipsum blabla..."
}
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
我将如何使用JavaScript编写一个查询ReQL为了获取汇总的所有条目(中entry具有)标题包含字符串"XYZ"?我希望查询结果返回一个匹配的条目对象数组,而不是匹配的feed数组.
假设我已经读了很多关于版本一个RESTful API,因此我决定不通过URI版本的服务,但使用mediatypes(格式和架构在请求接受头):
实现wcf服务或web api服务以提供定义uri中所请求资源的请求的最佳方式是什么,格式(例如,application/json)和schema中的schema/version(例如player-v2)头?
WCF允许我基于uri进行路由,但不基于标头.所以我不能正确路由.
Web Api允许我定义自定义mediatype格式,路由所请求的格式,但不是模式(例如,返回类型PlayerV1或PlayerV2).
我想实现一个服务(使用WCF或Web Api),对于此请求(伪代码):
api.myservice.com/players/123 Accept format=application/json; schema=player-v1
Run Code Online (Sandbox Code Playgroud)
以json格式返回PlayerV1实体
并为此请求:
api.myservice.com/players/123 Accept format=application/json; schema=player-v2
Run Code Online (Sandbox Code Playgroud)
以json格式返回PlayerV2实体.
有关如何实现这一点的任何提示?
编辑:为了澄清我为什么要使用内容协商来处理版本,请参见此处:REST API设计:将"类型"放在"内容类型"中.
我有一个表格的熊猫数据框
advert_id run_id category score
11111111 78 842 0.356975
11111111 78 849 0.245583
11111111 78 950 0.089219
11111111 78 1645 0.089172
11111111 78 2494 0.044254
... ... ... ...
22222222 1083267 2521 0.078275
22222222 1083267 2553 0.121556
22222222 1083267 2872 0.039226
22222222 1083267 3045 0.362127
22222222 1083267 3049 0.040135
Run Code Online (Sandbox Code Playgroud)
并希望将其转换为表单的数据框(现在每个 advert_id 一行):
advert_id run_id category_1 score_1 category_2 score_2 category_3 score_3 ... category_n score_n
11111111 78 842 0.356975 849 0.245583 950 0.089219 ...
22222222 1083267 2521 0.078275 2553 0.121556 2872 0.039226 …Run Code Online (Sandbox Code Playgroud)