Github のAPI を利用して Gist の情報を取得しようとしています。
https://developer.github.com/v3/gists/
この中で、Gist に含まれているファイル一覧を取得しようとしています。
できたらList<T> で取得したいです。
リクエストを送信してJson を取得するところまではできています。
環境の前提
現在 Moshi を使ってjson のパースを試みてますが、他のライブラリなら解決できるならそちらでも大丈夫です。
具体的に困ってること
Gist のAPI を叩くとファイルの部分では以下のようなJson が返ってくると書いてあります。
json
1"files": { 2 "hello_world.rb": { 3 "filename": "hello_world.rb", 4 "type": "application/x-ruby", 5 "language": "Ruby", 6 "raw_url": "https://gist.githubusercontent.com/octocat/6cad326836d38bd3a7ae/raw/db9c55113504e46fa076e7df3a04ce592e2e86d8/hello_world.rb", 7 "size": 167 8 } 9 },
しかし、ファイルが複数になる or gist のファイル名が変わった場合に取得する方法がわかりません。
(Moshi などに食べさせるJson の定義クラス?にはプロパティ名も入れなければいけないため)
複数ファイル存在するときの例
json
1"files": { 2 "hello_world.rb": { 3 "filename": "hello_world.rb", 4 "type": "application/x-ruby", 5 "language": "Ruby", 6 "raw_url": "https://gist.githubusercontent.com/octocat/6cad326836d38bd3a7ae/raw/db9c55113504e46fa076e7df3a04ce592e2e86d8/hello_world.rb", 7 "size": 167, 8 "truncated": false, 9 "content": "class HelloWorld\n def initialize(name)\n @name = name.capitalize\n end\n def sayHi\n puts \"Hello !\"\n end\nend\n\nhello = HelloWorld.new(\"World\")\nhello.sayHi" 10 }, 11 "hello_world.py": { 12 "filename": "hello_world.py", 13 "type": "application/x-python", 14 "language": "Python", 15 "raw_url": "https://gist.githubusercontent.com/octocat/e29f3839074953e1cc2934867fa5f2d2/raw/99c1bf3a345505c2e6195198d5f8c36267de570b/hello_world.py", 16 "size": 199, 17 "truncated": false, 18 "content": "class HelloWorld:\n\n def __init__(self, name):\n self.name = name.capitalize()\n \n def sayHi(self):\n print \"Hello \" + self.name + \"!\"\n\nhello = HelloWorld(\"world\")\nhello.sayHi()" 19 }, 20 "hello_world_ruby.txt": { 21 "filename": "hello_world_ruby.txt", 22 "type": "text/plain", 23 "language": "Text", 24 "raw_url": "https://gist.githubusercontent.com/octocat/e29f3839074953e1cc2934867fa5f2d2/raw/9e4544db60e01a261aac098592b11333704e9082/hello_world_ruby.txt", 25 "size": 46, 26 "truncated": false, 27 "content": "Run `ruby hello_world.rb` to print Hello World" 28 }, 29 "hello_world_python.txt": { 30 "filename": "hello_world_python.txt", 31 "type": "text/plain", 32 "language": "Text", 33 "raw_url": "https://gist.githubusercontent.com/octocat/e29f3839074953e1cc2934867fa5f2d2/raw/076b4b78c10c9b7e1e0b73ffb99631bfc948de3b/hello_world_python.txt", 34 "size": 48, 35 "truncated": false, 36 "content": "Run `python hello_world.py` to print Hello World" 37 } 38 }
よろしくお願いします。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/10/16 03:04