在使用空手道调整 json 响应方面需要帮助
Need help in tweaking the json response using Karate
是否可以将输出 1 调整为输出 2?
* def dataset = databaseMethods.runJsonQuery(result, query)
* def output1 = dataset
Then print dataset
* def output2 = { "recordset": "#(output1)" }
然后打印output2
Expected output what I need: { "recordset": [ [{"Account no" :"123", "Key" : "9989"}, {"Account no" :"345", "Key" : "9889"},{"Account no :"569", "Key" : "9989"}] }
正在打印的实际输出:
{"recordset": "[ [{\"Account no\" :\"123\", \"Key\" : \"9989\"}, {\"Account no\" :\"345\", \"Key\" : \"9889\"},{\"Account no\" :\"569\", \"Key\" : \"9989\"}] }
请告诉我如何调整 json 响应。
看起来像您需要的字符串 JSON。读这个:https://github.com/intuit/karate#type-conversion
所以你可以这样做:
* json output1 = dataset
是否可以将输出 1 调整为输出 2?
* def dataset = databaseMethods.runJsonQuery(result, query)
* def output1 = dataset
Then print dataset
* def output2 = { "recordset": "#(output1)" }
然后打印output2
Expected output what I need: { "recordset": [ [{"Account no" :"123", "Key" : "9989"}, {"Account no" :"345", "Key" : "9889"},{"Account no :"569", "Key" : "9989"}] }
正在打印的实际输出:
{"recordset": "[ [{\"Account no\" :\"123\", \"Key\" : \"9989\"}, {\"Account no\" :\"345\", \"Key\" : \"9889\"},{\"Account no\" :\"569\", \"Key\" : \"9989\"}] }
请告诉我如何调整 json 响应。
看起来像您需要的字符串 JSON。读这个:https://github.com/intuit/karate#type-conversion
所以你可以这样做:
* json output1 = dataset