0

現在、Twitch API を使用してライブ ストリームに関する情報を取得しています。ただし、視聴者などのストリームセクションの下のデータを取得できないようです。Maven の依存関係として json-simple を使用しています。

{
  "_links": {
"channel": "https://api.twitch.tv/kraken/channels/test_channel",
"self": "https://api.twitch.tv/kraken/streams/test_channel"},
"stream": {
"game": "StarCraft II: Heart of the Swarm",
"viewers": 2123,
"average_fps": 29.9880749574,
"delay": 0,
"video_height": 720,
"is_playlist": false,
"created_at": "2015-02-12T04:42:31Z",
"_id": 4989654544,
4

1 に答える 1

0

viewersデータを取得する例を次に示します。

JSONParser parser = new JSONParser();
// handle exceptions for this line
JSONObject jsonObject = (JSONObject) parser.parse(new FileReader(new File("data.json")));
JSONObject streamObject = (JSONObject) jsonObject.get("stream");
long viewers = (Long) streamObject.get("viewers");
于 2015-11-15T12:58:11.857 に答える