我希望能够检查两个条件是否为真,即空手道我有一个数据数组,我想通过以下方式进行验证
如果"文档":"ID">
然后"公民":"是"否则
如果"文件":"护照" 然后"公民":"否">
这是我要验证的数组数据
{
"id": 7777,
"name": "suzie",
"surname": "Nedbank",
"Documentation": "ID",
"citizen": "YES",
},
尝试的方法:
* def Doc_type = function(x) { return x == "ID" || x == "Passport"}
* match response ==
{
"id": 7777,
"name": "suzie",
"surname": "Nedbank",
"Documentation": "#? Device_type(_)",
"citizen": "#($.Documentation == "ID" ? "citizen" : "YES" || $.Documentation == "Passport" ? "citizen" : "NO" )"
}
错误: net.minidev.json.parser.ParseException: 意外令牌 |在位置 154。
这对我有用,也许它会给你一个提示:
* def response =
"""
{
"id": 7777,
"name": "suzie",
"surname": "Nedbank",
"Documentation": "ID",
"citizen": "YES",
}
"""
* def isCitizen =
"""
function(x){
var doc = $.Documentation;
if (doc == 'ID') return x == 'YES';
if (doc == 'Passport') return x == 'NO';
return false;
}
"""
* match response ==
"""
{
"id": 7777,
"name": "suzie",
"surname": "Nedbank",
"Documentation": "#string",
"citizen": "#? isCitizen(_)",
}
"""