Search code examples
jsonjmeterjsonpath

Need to extract a josn value for nested requests in JMeter using Jsonpath extractor


I have response which derived from a action. I need to extract a value of userid node using json path extractor in JMeter

{ "ABC": "{"response":{"userId":user1,"caseId":0,"name":"Json","email":"json@xyz.com","mobileNumber":"1223456789","countryCodeId":"1","countryCode":"+90","emailOTP":830782,"mobileOTP":301879,"mobileOTPString":null,"otpCreationDate":"2021-10-14T10:01:38.5802765Z","configOTPTimeOut":120,"redirectUrl":null,"isOTPExpired":false,"countryCodeValidMessage":null,"mobileNumberValidMessage":null,"offset":"00:00:00","postStatus":false,"postMessage":null,"id":null,"response":null,"isProceedToCreateMeeting":false},"successcode":0,"message":null}" }

I have tried $..ABC.response.userId, it says NoMatch. what is the correct syntax to extract userId node which is present inside response


Solution

  • What you're showing us is not a valid JSON (you can check it yourself using i.e. https://jsonlint.com/ website or equivalent) therefore you won't be able use either JSON Extractor or JSON JMESPath Extractor

    Unless it's a copy-paste issue you're limited to Regular Expression Extractor, example regular expression would be something like:

    "userId"\s*:\s*(.+?)\s*,
    

    enter image description here