我正在使用apache速度進(jìn)行json轉(zhuǎn)換。下面是我的 json 字符串 { "apiCode": "Payment Execution Service", "name": "Initiate a payment", "description": "Initiate a payment", "request": { "method": "POST", "path": "/api/v1/payments", "headers": [ { "Corporate-ID": "apiKey" }, { "Content-Type": "application/json" } ], "body": "{\n \"beneficiaryInformation\" : {\n \"destinationAccountIdentifier\" : \"string\",\n \"destinationBankIdentifier\" : \"DEUTDEDB237\",\n \"fullName\" : \"JASON SMITH\"\n },\n \"purposeOfPayment\" : \"Invoice Payment\",\n \"remittanceInformation\" : \"Mantainance of Fixtures\",\n \"remitterInformation\" : {\n \"sourceAccountCurrency\" : \"EUR\",\n \"sourceAccountIdentifier\" : \"string\",\n \"sourceBankIdentifier\" : \"DEUTDEDBFRA\"\n },\n \"transferAmount\" : 1.5,\n \"transferCurrency\" : \"EUR\",\n \"transferDate\" : \"2015-07-20\",\n \"transferType\" : \"SCTInst\",\n \"uniqueRequestNo\" : \"string\"\n}" }, "response": { "status": 200, "headers": [ { "Content-Type": "application/json" } ], "body": "{\n \"requestReferenceNo\" : \"string\",\n \"transactionStatus\" : {\n \"bankReferenceNo\" : \"string\",\n \"reasonCode\" : \"string\",\n \"statusCode\" : \"string\"\n }\n}" }, "provider": "Payment Execution Service"}下面是我的 .vm 文件 {"provider": { "name": "$arr[0].apiCode"},"consumer": { "name": "$arr[0].provider"},"interactions": [#set($i = 0)#foreach($a in $arr) { "description": "$a.description", "request": { "path": "$a.request.path", "method": "$a.request.method", "headers": $json.valueToString($a.request.headers), "body": $json.valueToString($a.request.body) },
使用 apache Velocity 進(jìn)行 JSON 到 JSON 轉(zhuǎn)換?有沒有更好的方法來編寫我在
慕的地8271018
2022-09-28 14:24:28