Gatling - 从JSON数组响应中提取数据

时间:2017-02-16 15:20:26

标签: arrays json gatling jsonpath

如果我有这种回应:

.check(jsonPath("$..CCC").saveAs("VARIABLE"))

如何在列表中以其他方式获得所有值CCC?

如果我使用:

import praw
import time

r = praw.Reddit('testmachine11968986531')
test = r.submission(id="5u7q8x")

comment_user = set()   # to avoid duplicates

for i in xrange(0,10):  # Run the loop 10 times
    #comments = r.comments(submission)
    for comment in test.comments:
        body = comment.body.lower()
        if body.find("think") != -1 or body.find("please") != -1:
            comment_user.add(comment.author)
    #time.sleep(120)   # Sleep for 2 minutes

print "Here are some comments:"
for user in polite_users:
    print user

我只获得第一个CCC(" abcde")。通过CCC [*]执行此操作会引发错误。

1 个答案:

答案 0 :(得分:3)

我认为,您应该在check语句中添加findAll。

例如:

.check(jsonPath("$..[*].CCC").findAll.saveAs("VARIABLE"))

请定义您的错误。

干杯, Peekay