JSONPATH过滤器中未替换嵌入式表达式 [英] Embedded expressions are not replaced in the JSONPATH filter
问题描述
当我传递字符串json过滤器的值时,它工作正常.但是,当我在JSONPATH中传递嵌入式表达式时,它并不能替代实际值.
When i am passing the value of a string json filter is working fine. But when I am passing embedded expression in the JSONPATH it is not replacing actual value.
Given url appServer +'/integration/rest/user'+'?page=0'+'&pageSize=10'+'&fieldList=first_name,last_name,id,username,last_login,active,date_created'+'&filter=user_type%20equals%20%27P%27%20'+'&getTotalRecordCount=true'
头X-CSRF-TOKEN = csrfToken * Cookie JSESSIONID = jsessionid *打印路线值 * Cookie路线=路线值 *字符串searchUser ='anupama'
And header X-CSRF-TOKEN = csrfToken * cookie JSESSIONID = jsessionid * print routevalue * cookie route = routevalue * string searchUser = 'anupama'
方法获得时 然后状态200 * def用户名=获取response.integration.serviceData.record [*].用户名 *打印用户名 *打印searchUser * def userNode = get [0] response.integration.serviceData.record [?(@.username =='#(searchUser)')] *打印userNode
When method get Then status 200 * def usernames = get response.integration.serviceData.record[*].username * print usernames * print searchUser * def userNode = get[0] response.integration.serviceData.record[?(@.username== '#(searchUser)')] * print userNode
推荐答案
Embedded expressions are only for JSONPath and XML: https://github.com/intuit/karate#embedded-expressions
请对动态JsonPath使用karate
API: https://github.com/intuit/karate#jsonpath-filters
Please use the karate
API for dynamic JsonPath: https://github.com/intuit/karate#jsonpath-filters
* def userNode = karate.jsonPath(response, "$.integration.serviceData.record[?(@.username=='" + searchUser + "')]")
这篇关于JSONPATH过滤器中未替换嵌入式表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!