応答が 2 つの条件を満たしている「dependentPreferences」の「説明」の値を返そうとしています。まず、名前が「John Smith」であるかどうかを確認し、次に設定の「画像」が「papaya.jpg」と等しいかどうかを確認します。 .
応答本文は次のとおりです。
[
{
"id": 1,
"name": "John Smith",
"description": null,
"shortDescription": "No recorded interests.",
"alias": "JS",
"preferences": [
{
"id": 1,
"description": "likes candy and papaya",
"image": "papaya.jpg",
"name": "Papaya",
"dependentPreferences": [
{
"id": 1,
"description": "Fruit must be ripe",
"image": "ripe-papaya.jpg",
"name": "pap"
}
]
}
]
},
{
"id": 2,
"name": "Jane Smith",
"description": null,
"shortDescription": "No recorded interests.",
"alias": "JS",
"preferences": [
{
"id": 1,
"description": "likes candy and papaya",
"image": "papaya.jpg",
"name": "Papaya",
"dependentPreferences": [
{
"id": 1,
"description": "Candy must be Skittles",
"image": "Skittles.jpg",
"name": "skt"
}
]
}
]
}
]
これまでのところ、私は次のようなことを試しました:
response.jsonPath().getString("find { it.name == 'John Smith' }.preferences.find {it.image == 'papaya.jpg'}.dependentPreferences.description
しかし、構文について不平を言っています。コードのこの部分が画像を見つけるために機能することはわかっています。
response.jsonPath().getString("find { it.name == 'John Smith' }.preferences.image
しかし、私は2番目の条件を構築するのに苦労しています. どんな助けでも大歓迎です。