应我的请求,我得到以下答复,
{
"studyDTO": {
"studyId": 191,
"studyCode": "test_ispptest2"
},
"sites": [],
"subjects": [],
"visits": [],
"sftpLocations": [],
"dicomLocations": [],
"fileSystemLocations": [],
"rawFileSystemLocations": [],
"states": null,
"modalities": [
{
"studyId": 191,
"submitValue": "ct",
"displayValue": "Conventional CT",
"orderOfDisplay": 30
},
{
"studyId": 191,
"submitValue": "multi_slice_spiral_ct",
"displayValue": "Multi-Slice Spiral CT",
"orderOfDisplay": 50
},
{
"studyId": 191,
"submitValue": "dxa",
"displayValue": "DXA",
"orderOfDisplay": 60
},
{
"studyId": 191,
"submitValue": "mri",
"displayValue": "MRI",
"orderOfDisplay": 100
},
{
"studyId": 191,
"submitValue": "unknown",
"displayValue": "Unknown",
"orderOfDisplay": 240
}
],
"examDates": [],
"series": null,
"transferType": null,
"customFolder": false,
"customFile": false,
"folderStructure": null,
"fileStructure": null,
"allSites": true,
"allSubjects": true,
"allVisits": true,
"allStates": false,
"allExamDates": true,
"allModalities": false,
"allSeries": false,
"softEditOverride": false,
"includePS": false,
"includeSR": false,
"includeRTStruct": false,
"dicomTemplate": null,
"errorMessage": null,
"successMessage": null
}
在响应中,我收到的5 modality
值可以更多,在JSON类型的下一个请求主体中,我希望添加所有modalities
,我如何使用JSR223后处理器来完成此操作,
申请样品:
{
"studyDTO": {
"studyId": 191,
"studyCode": "test_ispptest2"
},
"allVisits": true,
"modalities": [
{
"studyId": 191,
"submitValue": "ct",
"displayValue": "Conventional CT",
"orderOfDisplay": 30
},
{
"studyId": 191,
"submitValue": "multi_slice_spiral_ct",
"displayValue": "Multi-Slice Spiral CT",
"orderOfDisplay": 50
},
{
"studyId": 191,
"submitValue": "dxa",
"displayValue": "DXA",
"orderOfDisplay": 60
},
{
"studyId": 191,
"submitValue": "mri",
"displayValue": "MRI",
"orderOfDisplay": 100
},
{
"studyId": 191,
"submitValue": "unknown",
"displayValue": "Unknown",
"orderOfDisplay": 240
}
],
"includePS": null
}
到目前为止我已经开发了,但是不知道如何形成请求JSON
import groovy.json.JsonSlurper
def jsonString = prev.getResponseDataAsString();
def jsonConvert = new JsonSlurper();
def object = jsonConvert.parseText(jsonString);
def modalityS = object.modalities.size().toString();
def modalitySize = modalityS?.isInteger() ? modalityS.toInteger() : null
for (int i = 0; i < modalitySize ; i++) {
def modalityOrderOfDisplay = object.modalities[i].orderOfDisplay;
def modalSubmitValue = object.modalities[i].submitValue;
def modalDisplayValue = object.modalities[i].displayValue;
log.info('----------------------->'+modalityOrderOfDisplay);
log.info('----------------------->'+modalSubmitValue);
log.info('----------------------->'+modalDisplayValue);
}
1条答案
按热度按时间niknxzdl1#
看一看JsonBuilder类
类似于:
应该能帮上忙。
如果需要,您可以将生成的请求正文引用为
${request}
。更多信息: