本文介绍了如何从github API解析链接标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

github API会将json结果的分页数据发送到http链接标头中:

 链接:< https: //api.github.com/repos?page=3&per_page=100> ;; rel =next,
< https://api.github.com/repos?page = 50& per_page = 100>; rel =last

因为github API不是唯一使用这种方法的API(我想)我想问一下,如果有人有一个有用的小片段来解析链接头(例如,将其转换为数组),以便我可以将它用于我的js应用程序。



有一个在,它显示了如何解析链接标题。


the github API sends the pagination data for the json results in the http link header:

Link: <https://api.github.com/repos?page=3&per_page=100>; rel="next",
<https://api.github.com/repos?page=50&per_page=100>; rel="last"

since the github API is not the only API using this method (i think) i wanted to ask if someone has a useful little snippet to parse the link header (and convert it to an array for example) so that i can use it for my js app.

i googled around but found nothing useful regarding how to parse pagination from json APIs

解决方案

There is a PageLinks class in the GitHub Java API that shows how to parse the Link header.

这篇关于如何从github API解析链接标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 16:15