如何从 SOAPUI 中的 Json 响应中提取子字符串值

How to extract a substring value from Json response in SOAPUI

我正在尝试从字符串形式的消息中获取 requestID。

{
   "version": "1.0.0-80",
   "status": 201,
   "error": "MSG004",
   "uuid": "aae1bb59-da3f-4118-a4a4-asdfsdfsd",
   "message": "Successfully created a request with an id of 1234",
   "path": "/api/request/",
   "timestamp": "2019-03-21T09:41:58.484"
}

谁能帮我从消息中创建一个属性,我只需要在这句话的末尾传递请求ID:

"Successfully created a request with an id of 1234"

谢谢

使用直接的子字符串应该可以解决问题。

def id = variableThatContainsTheString.substring(46)

但这并不漂亮。但您正在测试的解决方案也不是。

我认为,如果 ID 应该由 Web 服务的使用者使用,那么它确实应该以其自己的键值传递。应该没有必要从字符串中删除它。

响应可能是这样的:

{ 
  "version": "1.0.0-80",
  "status": 201, 
  "error": "MSG004", 
  "uuid": "aae1bb59-da3f-4118-a4a4-asdfsdfsd", 
  "message": "Successfully created a request with an id of 1234", 
  "path": "/api/request/", 
  "timestamp": "2019-03-21T09:41:58.484",
  "id": "1234" 
}

告诉开发人员齐心协力。 ;-)