可选字段可以使用 # 符号 (##number) 进行验证。 我需要验证我的响应中的可选对象。 listValues 是响应中的可选对象。我如何检查这一点,因为我收到错误,因为实际不包含键 - 'listValues',因为第一个对象没有 listValues。如何将其设为可选
{"filter": {
"ITEM": {
"ITEM": [
{
"m_operators": ["A", "B"],
"operators": ["A1", "B1"],
"logicalDataType": "STRING",
"tableName": "ITEM"
},
{
"m_operators": ["C", "D"],
"operators": ["C1", "D1"],
"logicalDataType": "STRING",
"tableName": "ITEM"
},
{
"m_operators": ["E", "F"],
"operators": ["E1", "F1"],
"logicalDataType": "String",
"listValues": [
{
"m_key": "String",
"m_value": "String"
},
{
"m_key": "String",
"m_value": "String"
}
],
"tableName": "ITEM"
}
]
}
}}
* def listValuesSchema = {"m_key": "#string", "m_value": "#string}
* def itemsSchema = {"m_operators": "#[] #string", "operators": "#[] #string", "logicalDataType": "#string", "listValues": "#[] ##(listValuesSchema)", "tableName": "#string"}
* def filterSchema = {"ITEM": {"ITEM": "#[] ##(itemsSchema)"}}
* def jsonExpected = {"filter": "#(filterSchema)"}
* match response == jsonExpected