JSON值如何使用正则表达式提取器提取jmeter响应数据中的进程

时间:2021-08-12 13:22:54
{  
  "response":{  
    "statusCode":"00",
    "status":"success",
            "responseData":
             [
                   {  
                     "status":1,
                     "themeID":27,
                     "themeName":"ThemeName25",
                     "templateId":22
                    }
             },
                  {  
                     "status":1,
                     "themeID":28,
                     "themeName":"ThemeName28",
                     "templateId":28
                  }
             }
             ]
}

Here need to extract the json values from first and second array But without the use of jmeter plugins like JSON PATH EXTRACTOR. Can anyone suggest the idea for this?

这里需要从第一个和第二个数组中提取json值但不使用像JSON PATH EXTRACTOR这样的jmeter插件。任何人都可以提出这个想法吗?

1 个解决方案

#1


2  

Regular Expression Extractor is usually much faster compared to other extractors like XPath, JSON etc - Check this site for the comparison.

与其他提取器(如XPath,JSON等)相比,正则表达式提取器通常要快得多 - 请检查此站点以进行比较。

Lets assume we are trying to get the value of all the theme ids from the JSON. Add a Regular Expression Extractor and update the details as shown here.

让我们假设我们试图从JSON中获取所有主题ID的值。添加正则表达式提取器并更新详细信息,如此处所示。

JSON值如何使用正则表达式提取器提取jmeter响应数据中的进程

  1. You need a reference name to store the value found
  2. 您需要一个引用名称来存储找到的值
  3. The pattern to check
  4. 要检查的模式
  5. Template used to create a string from the matches found
  6. 用于从找到的匹配项创建字符串的模板
  7. -1 for all matches, 0 for random, 1 for first ..etc
  8. -1表示所有匹配,0表示随机,1表示第一个..等等

JSON值如何使用正则表达式提取器提取jmeter响应数据中的进程

  1. <variable>_matchNr will give the total matches
  2. _matchNr将给出总匹配
  3. theme.id_1 will return the first match which is 27
  4. theme.id_1将返回第一个匹配的27
  5. theme.id_2 will return the second match which is 28
  6. theme.id_2将返回第二个匹配,即28

More details and examples are here.

更多细节和示例在这里。

#1


2  

Regular Expression Extractor is usually much faster compared to other extractors like XPath, JSON etc - Check this site for the comparison.

与其他提取器(如XPath,JSON等)相比,正则表达式提取器通常要快得多 - 请检查此站点以进行比较。

Lets assume we are trying to get the value of all the theme ids from the JSON. Add a Regular Expression Extractor and update the details as shown here.

让我们假设我们试图从JSON中获取所有主题ID的值。添加正则表达式提取器并更新详细信息,如此处所示。

JSON值如何使用正则表达式提取器提取jmeter响应数据中的进程

  1. You need a reference name to store the value found
  2. 您需要一个引用名称来存储找到的值
  3. The pattern to check
  4. 要检查的模式
  5. Template used to create a string from the matches found
  6. 用于从找到的匹配项创建字符串的模板
  7. -1 for all matches, 0 for random, 1 for first ..etc
  8. -1表示所有匹配,0表示随机,1表示第一个..等等

JSON值如何使用正则表达式提取器提取jmeter响应数据中的进程

  1. <variable>_matchNr will give the total matches
  2. _matchNr将给出总匹配
  3. theme.id_1 will return the first match which is 27
  4. theme.id_1将返回第一个匹配的27
  5. theme.id_2 will return the second match which is 28
  6. theme.id_2将返回第二个匹配,即28

More details and examples are here.

更多细节和示例在这里。