简体   繁体   English

如何使用正则表达式提取器提取jmeter中的Json值?

[英]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. 在这里,我只需要使用正则表达式提取器来检索templateIdthemeName的值,而不是通过JSON路径提取器之类的jmeter插件来检索。 Can anyone having for this solution?? 任何人都可以使用此解决方案吗?

Use the regexen 使用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. 一种假设是templateId值在结构上是数字。

To Capture templateId: templateId":(\\d+) 捕获templateId: templateId":(\\d+)
To Capture themeName: themeName":"(.+?)" 捕获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 \\ d-任何数字

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用正则表达式提取器在jmeter中提取json响应数据? - how to extract json response data in jmeter using regular expression extractor? 如何使用正则表达式提取器在jmeter响应数据中提取JSON值 - How the JSON value extract process in jmeter response data using regular expression extractor 使用jmeter中的正则表达式提取器从响应类型的json数据中提取数据 - extract data from reponse typed json data using Regular Expression Extractor in jmeter 使用 JMeter 中的正则表达式提取器从 JSON 中获取值 - Fetch value from JSON using regular expression extractor in JMeter 在Jmeter中使用正则表达式提取器提取JSON响应 - Extracting JSON Response using regular expression extractor in Jmeter 使用正则表达式提取器从jmeter响应中提取json - Extracting json from jmeter response using regular expression extractor Jmeter正则表达式提取器获取JSON结构 - Jmeter Regular expression extractor get JSON structure 如何在jmeter中使用正则表达式提取器从多个数组响应数据中检索JSON值? - How to retrieve the JSON value from multiple array response data using regular expression extractor in jmeter? 如何使用 Json Extractor 从 Jmeter 中嵌套的 Json 中提取数据 - How to extract data from nested Json in Jmeter using Json Extractor 如何在 JMeter 中使用 JSON 提取器提取 JSON 响应中的嵌套元素 - How to extract nested elements in JSON response using JSON extractor in JMeter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM