Jump to content


Parsing JSON from response body and putting it into a variable


  • Please log in to reply
2 replies to this topic

#1 Guest_KirkL_*

Guest_KirkL_*
  • Guests

Posted 14 May 2012 - 04:54 PM

I am new to WAPT and having trouble taking JSON from the response body, putting it into a variable, then using it on a subsequent request body.

I have the JSON module installed and am using WAPT 7.5.

My response body on one request is JSON that looks like the following:

[
{ "name":"john" },
{ "Id":10 }
]

I simplified it considerably, but debugged into a Javascript file where I copied the output to make sure I know the syntax.

In the end I need <object>[1].Id. So I created a "Response processing" variable named "userId" and added a "JSON Text" function for it to get "[1].Id", but I know I am missing something. It's like I need "$Var(Respose_Body)[1].Id" or something.

Any ideas?

In the next request I used $Var(userId) in the request body, but it just shows up as hard-coded "[1].Id" instead of my value.

#2 Sergei Leonov

Sergei Leonov

    Advanced Member

  • Administrators
  • PipPipPip
  • 663 posts

Posted 15 May 2012 - 07:36 AM

Could you give me your profile or send it to support?
Sergei Leonov
WAPT Project Manager
SoftLogica LLC

Office: +7-383-335-6692
Toll-free: 1-888-364-6797 (for US only)
Time zone GMT +6, EST +11
E-mail: support@loadtestingtool.com
http://www.loadtestingtool.com

#3 Guest_KirkL_*

Guest_KirkL_*
  • Guests

Posted 16 May 2012 - 02:29 PM

Could you give me your profile or send it to support?


I figured it out and was unable to delete my thread yesterday since it hadn't gone through the moderator yet. I was looking through the help docs and didn't notice that there was a separate help doc for the JSON module. Once I found that I realized that $JPath was what I needed.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users