简体   繁体   中英

How to extract the Json values in jmeter using regular expression extractor?

{  
  "response":{  
    "statusCode":"00",
    "status":"success",
            "responseData":{  
                     "status":1,
                     "themeID":27,
                     "themeName":"ThemeName25",
                     "templateId":22
                           }
             }
}

Here i need to retrieve the value of templateId , themeName using regular expression extractor only not by jmeter plugins like json path extractor. Can anyone having for this solution??

Use the regexen

/"themeName":"([^"]+)"/
/"templateId":([0-9]+)/

to capture the result.

This goes by the usual caveat that it is strongly discouraged to use regex patterns as parser substitutes

One assumption is that values for templateId are structly numeric.

To Capture templateId: templateId":(\\d+)
To Capture themeName: themeName":"(.+?)"

The special characters above are:
( and ) - these enclose the portion of the match string to be returned
. - match any character
+ - one or more times
? - stop when first match succeeds
\\d - for any digit

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM