如果查询参数出现在JSON-API响应中的链接是百分比编码的?应该对json-api响应中的链接进行编码吗?
从jsonapi.org所述实施例不编码,如在:
{
"links": {
"self": "http://example.com/articles",
"next": "http://example.com/articles?page[offset]=2",
"last": "http://example.com/articles?page[offset]=10"
},
"data": [{
"type": "articles",
"id": "1",
"attributes": {
"title": "JSON API paints my bikeshed!"
}
]
}
然而,还存在关于请求编码参数的说明:
GET /articles?include=author&fields[articles]=title,body&fields[people]=name HTTP/1.1
Accept: application/vnd.api+json
注:上面的示例URI显示未编码[和]字符只是为了便于阅读。实际上,这些字符必须按照RFC 3986中的要求进行百分比编码。
本笔记是否仅适用于请求?还是应该反应也是百分比编码,如:
{
"links": {
"self": "http://example.com/articles",
"next": "http://example.com/articles?page%5Boffset%5D=2",
"last": "http://example.com/articles?page%5Boffset%5D=10"
},
"data": [{
"type": "articles",
"id": "1",
"attributes": {
"title": "JSON API paints my bikeshed!"
}
]
}