我似乎无法确认是否为用户分配了角色。我尝试过使用JSON Extractor元素和jp @ gc - JSON Path Assertion元素。无论哪种方式,它似乎都无法获取真值或假值。我一直在使用我方便的帮助工具http://jsonpath.com/来找到正确的JSON路径。在提取器和断言中,我有一个JSON路径=
$.[?(@.productDisplayName=='User Access')].[?(@.name=='CUSTOMER_ADMIN')].assigned
我希望得到的值= true但是由于一些奇怪的原因,这个回复并没有让我确认这个值。我得到的JSON Path Assert的响应是:
Assertion error: false
Assertion failure: true
Assertion failure message: Value expected to be 'true', but found '[]'
如果我尝试JSON提取,变量似乎永远不会得到一个值,甚至不是[true]!
非常感谢任何帮助。
以下是回复:
{
"@rpc": "1.0",
"@types": [
"com.test.blah.user.ProductRoleSecurity",
"com.test.blah.user.ProductRoleCategory",
"com.test.blah.user.ProductRoleAssignment"
],
"@data": [
{
"@type": 0,
"productRoleCategories": [
{
"@type": 1,
"categoryDescriptionLocaleKey": "blah.product.label.category.default.description",
"categoryDisplayName": "Default",
"categoryKey": "default",
"categoryDisplayLocaleKey": "blah.product.label.category.default.displayName",
"roleAssignments": [
{
"@type": 2,
"displayName": "Customer Administrator",
"requiredAttributes": [],
"name": "CUSTOMER_ADMIN",
"description": "Standard customer administrator role",
"assigned": true,
"roleCategoryString": "CUSTOMER_ADMIN:na:assigned=true"
},
{
"@type": 2,
"displayName": "U.P. Test",
"requiredAttributes": [],
"name": "UP-TEST",
"description": "Test for user provisionable",
"assigned": false,
"roleCategoryString": "UP-TEST:na:assigned=false"
}
],
"categoryDescription": "Default"
}
],
"productDisplayName": "User Access",
"productName": "UA",
"productDescription": "User Access"
},
{
"@type": 0,
"productRoleCategories": [
{
"@type": 1,
"categoryDescriptionLocaleKey": "blah.product.label.category.default.description",
"categoryDisplayName": "Default",
"categoryKey": "default",
"categoryDisplayLocaleKey": "blah.product.label.category.default.displayName",
"roleAssignments": [
{
"@type": 2,
"displayName": "User",
"requiredAttributes": [],
"name": "USER",
"description": "Other product User role",
"assigned": true,
"roleCategoryString": "USER:na:assigned=true"
},
{
"@type": 2,
"displayName": "Super User",
"requiredAttributes": [],
"name": "SUPER_USER",
"description": "Super User role",
"assigned": false,
"roleCategoryString": "SUPER_USER:na:assigned=false"
}
],
"categoryDescription": "Default"
}
],
"productDisplayName": "Other Product",
"productName": "SDR",
"productDescription": "Other Product"
}
]
}
答案 0 :(得分:0)
您的JSON路径查询与任何内容(两个部分)都不匹配,而且,您试图以奇怪的方式组合2个子句。
您需要将其修改为:
$..[?(@.productDisplayName=='User Access' && @.productRoleCategories[0].roleAssignments[0].name=='CUSTOMER_ADMIN')].productRoleCategories[0].roleAssignments[0].assigned
演示:
参考文献: