我一直在思考如何正确实现 Spring Cloud Contract Verifier,但是我试图通过合同强制执行的 JSON 很复杂,而且我不确定如何在 Groovy 表示中处理它。JSON 主体有时包含键的子对象,有时包含对象数组。
response {
status(200)
headers { contentType applicationJson() }
body(
"attrbte1": 777310402,
"attrbte2": 100,
"attrbte3": "CAPSULE",
"attrbte4": "01655",
"attrbte5": "281604",
"attrbte6": "28160420",
"genericCodeNo": 16353,
"stc": {
"stcAttrbt1": 10000001600,
"stcAttrbt2": "8875",
"stcAttrbt3: "2008-08-04T00:00:00.000+0000",
"stcAttrbt4": null
},
"gtc": {
"gtcAttbt1": 10000000028,
"gtcAttbt2": "0N",
"gtcAttbt3": "2008-08-04T00:00:00.000+0000"
},
"etcs": [
{
"etcAttbt1": 530,
"etcAttbt2": null,
"etcAttbt3": null
}
],
"icds": [
{
"icdCode": "F31.3",
"icdCode2": "F45.232"
},
{
"icdCode": "F40.01",
"icdCode2": "F44.2341"
}
]
) …
Run Code Online (Sandbox Code Playgroud)