JMeter:如何获取JSON路径中的坐标

问题描述 投票:-1回答:1

我在JSON路径中采用坐标时遇到一些问题。我想在链接中使用id 8352。我想要没有蜇和逗号的id。就像这个“8352”。

这是我的JSONPath语法:$ .issue [1] .diagnostics [42,43,44,45]

这是我的JSON路径:

`

{
  "issue": [
    {
      "severity": "information",
      "diagnostics": "No issues detected during validation",
      "code": "informational"
    },
    {
      "severity": "information",
      "diagnostics": "Successfully created resource Observation/8352/_history/1",
      "code": "informational"
    }
  ],
  "text": {
    "div": "<div xmlns=\"http://www.w3.org/1999/xhtml\"><h1>Operation Outcome</h1><table border=\"0\"><tr><td style=\"font-weight: bold;\">information</td><td>[]</td><td><pre>Successfully created resource &quot;Observation/8352/_history/1&quot; in 9ms</pre></td>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t\t<tr>\n\t\t\t\t<td style=\"font-weight: bold;\">information</td>\n\t\t\t\t<td>[]</td>\n\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\n\t\t\t\t\t\t<td><pre>No issues detected during validation</pre></td>\n\t\t\t\t\t\n\t\t\t\t\n\t\t\t</tr>\n\t\t</table>\n\t</div>",
    "status": "generated"
  },
  "resourceType": "OperationOutcome"
}`

This is my JSON evaluation result: 

`[
  "8",
  "3",
  "5",
  "2"
]`
json jmeter evaluation
1个回答
0
投票

你将无法使用JSON value提取部分JSON Extractor,更好的想法将改为Regular Expression Extractor,相关的正则表达式将是这样的:

Observation/(\d+)/

其中\d+代表Observation之后的斜杠之间的任意位数。

演示:

enter image description here

更多信息:JMeter: Regular Expressions

© www.soinside.com 2019 - 2024. All rights reserved.