-1
これは私のJSONの一部(元に、私は多くの同じ部分を持っている)である。安心してこのようにJSONからデータを検証して取得するにはどうすればよいですか?
{
"content": [
{
"id": "20d4719a9-5636236-1015a2626e78",
"title": "CONC",
"filename": "3543543634634.ts",
"resolution": "4k",
"details": {
"description": "CC",
"genres": [
"standard"
],
"duration": "107",
"release": "Jan 26 2014 11:01AM",
"tags": "043543534534",
"rating": "G",
"expires": "25235353460",
"added": "150353535724113",
"frameRate": "60",
"type": "br-ca",
"deletable": "true",
"outputRange": "sdr",
"outputResolution": "4k",
"enabledDate": "1335353420",
"channel": "",
"actionId": "playback",
"resolution": "4k",
"supportedResolutions": "4k",
"supportedModels": "",
"unsupportedModels": "",
"supportedAudioModels": "",
"audioLevel": "0",
"fileId": "58ba025325252001ea263",
"metadata": null,
"bitdepth": "b8",
"colorspace": "cAuto",
"artist": "N\/A",
"album": ""
},
"status": {
"state": "playable",
"download": {
"size": "62713254232",
"bytes": 0,
"position": -1
},
"playback": {
"viewCount": "0",
"position": "0"
}
},
"categories": [
{
"id": "b91667fjhfg07457ff",
"name": "HOME",
"language": "br-ca",
"translation": "HOME",
"state": "playable"
}
],
"images": [
{
"id": "7c9anx5y4u44u433u5b3d3ccf3",
"uri": "041thddhdhdhdrh.png",
"width": "232",
"height": "131",
"row": "0",
"column": "0",
"action": "button"
},
{
"id": "dhsdhrdrhdr54y6y",
"uri": "dfhe45h334.png",
"width": "294",
"height": "160",
"row": "1",
"column": "1",
"action": "playback"
},
{
"id": "hrh35h3h333h",
"uri": "3h33h3h3hdfhdhd.png",
"width": "294",
"height": "160",
"row": "1",
"column": "2",
"action": "loop"
},
{
"id": "3y3y3g3g43g3",
"uri": "fghfghf554h5445h.png",
"width": "294",
"height": "160",
"row": "1",
"column": "3",
"action": "loop"
},
{
"id": "54h45h54h54h",
"uri": "fjfgj464545g35demo.png",
"width": "294",
"height": "160",
"row": "2",
"column": "1",
"action": "loop"
},
...
どこ名==「HOME」私は、すべてのカテゴリを見つける必要があります。 そして、そのカテゴリのコンテンツ名(content.name)を取る
他のカテゴリの同じ必要性があります。だからカテゴリ別にソートしてコンテンツ名で印刷したいと思っています。
私はこのコードを持っていますが、検証名== "HOME"は機能しないので、何か間違っているように見えます。
package GET;
import org.testng.annotations.Test;
import java.util.List;
import static io.restassured.RestAssured.get;
import static io.restassured.path.json.JsonPath.from;
public class GetContent {
@Test
public void parseContent() {
String response = get("http://192.168.1.139/v1/content/").asString();
List<String> list = from(response).getList("content.categories.findAll {it.name == 'HOME'}.name");
int a = list.size();
System.out.println("List Size: " + a);
System.out.println(list);
}
ご意見はありますか?おかげさまで