Looping through Json array

264 views
Skip to first unread message

Guruprasad Gopalakrishna

unread,
Sep 19, 2013, 7:18:39 PM9/19/13
to gat...@googlegroups.com
Hi ,

I am using Json compile , whose output is Jsonarray (["12","13,"14"]). Now i need do loop through them and execute some set of actions and provide each content in array as input for each iteration. I tried for each but i could not figure out. Please let me know
Package is : net.minidev.json.JSONArray

val imageAreaId : JSONArray = JsonPath.compile("$..imageAreas[*].id").read(pageData)

Regards
Guru

Stéphane Landelle

unread,
Sep 20, 2013, 6:17:59 AM9/20/13
to gat...@googlegroups.com
Could you share a gist please?


2013/9/20 Guruprasad Gopalakrishna <guruk...@gmail.com>

--
You received this message because you are subscribed to the Google Groups "Gatling User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gatling+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Guruprasad Gopalakrishna

unread,
Sep 20, 2013, 1:39:37 PM9/20/13
to gat...@googlegroups.com
Hi,
This is my scenario, I have a service which returns JSP and json is a part of output. So as you had suggested before I am doing regex to extract json and storing in my session. 
 regex("""pageData\s=\s([^;]*)""").saveAs("pageData")

 Then I am doing Jsonpath compile as below

val imageAreaIds : JSONArray  = JsonPath.compile("$..imageAreas[*].id").read(pageData)
 session2 = session2.setAttribute("imageAreaIds",imageAreaIds)

Now i need to use these imageAreaIds and run the test as many times i have ImageAreaIds.

Regards
Guru
Reply all
Reply to author
Forward
0 new messages