我有这个布局的JSON对象:
{
"events": [{
"type": "page",
"sessionId": "d9e3643a-5126-4ee4-bcc8-5fa1b4fdf52b",
"changes": {
"changes": [{
"model": {
"styles": ["bold"],
"name": "TextItem",
},
"type": "update",
"key": "1"
}, {
"model": {
"styles": [],
"name": "TextItem",
"plainText": "Skoda Octavia",
},
"type": "textitem",
"properties": {}
,
"type": "update",
"key": "2"
}, {
"model": {
"questionText": "Bouwjaar",
"validations": [{
"message": "Dit veld is verplicht",
}, {
"message": "Voer een geldig bouwjaar op.",
}
}
],
**"messages": [{
"text": "Dit veld is verplicht",
"type": "ERROR"
}**
],
"name": "Motorrijtuig.Bouwjaar"
},
"type": "update",
"key": "3"
}}]}]}
我想验证带有questionText ='Bouwjaar'的模型有message.text ='Dit veld is verplicht'
解决方案可能是: $ {test} =评估| '$ {JSON ['events'] [0] ['changes'] ['changes'] [2] ['model'] ['messages'] [0] ['text']}'=='Dit veld是verplicht'
但是有了新的更新,索引可能会被更改,我的测试将失败。
我现在的解决方案是: 对于每个modelobject - >检查questionText是否在modelobject中 - >是 - >检查questionText = Bouwjaar - >是 - >检查消息 在我的jsonobject中有14个modelobjects
是否有更简单的方法来检查message.text,而不是de indexcontext?