Azure API Set-body JSON to JSON covert

Azure API Set-body JSON to JSON covert

我得到的响应在下面,我需要将输入 JSON 格式转换为其他 JSON 结构并发回响应。我很惊讶如何从 JSOn 获取数据并构建新的 JSON 格式

{
  "totalSize": 1,
  "done": true,
  "records": [{
    "attributes": {
      "type": "test123",
      "url": "/services/data/testapp"
    },
    "Id": "8373837",
    "Name": "6294",
    "Application": "9932932932",
    "contact": {
      "attributes": {
        "type": "testcon",
        "url": "/services/data/testappsss"
      },
      "Name": "testName",
      "FirstName": "test",
      "LastName": "name",
      "MailingStreet": null,
      "MailingCity": null,
      "unemail": "testname@test,.co",
      "MailingState": null,
      "MailingCountry": null,
      "MailingPostalCode": null,
      "stuId": "328237832"
    },
    "currentusbss": "83277832873278",
    "currentsu": {
      "attributes": {
        "type": "testsub",
        "url": "/services/data/v44.0jsjsj"
      },
      "price": 2,
      "Name": "SUB-20426"
    },
    "bal": 234,
    "startdate": "2020-02-03",
    "enddate": "2020-05-03"
  }]
}

我需要将上面的 JSON 格式转换为下面的 JSON 格式,并在绑定策略中使用 set-body 方法发送它

{
  "info": {
    "studentName": "testName",
    "studentFirstName": "test",
    "studentMiddleName": "",
    "studentLastName": "Name",
    "studentEmail": "testname@test,.co",
    "role": "STUDENT",
    "billingCountryCode": "US",
    "systemId": "XX",
    "stuId": "328237832"
  },
  "address": {
    "address1": "1234 Grove St",
    "address2": "",
    "city": "Tempe",
    "countryCode": "US",
    "countryDescription": "UNITED STATES",
    "stateCode": "AZ",
    "stateDescription": "Arizona",
    "postalCode": "45235",
    "foreignState": "Arizona",
    "region": "Domestic",
    "phoneNumber": ""
  },
  "account": {
    "institutionId": "1",
    "paymentPlan": "N",
    "currencyDesc": "United States Dollars",
    "currencyType": "USD",
      "bal": 234,
      "daysLate":"18",
      "opportunityId": "9932932932",
      "studentParameterName": null,
    "studentParameterValue": null
  },
  "studentTerms": [
    {
        "startdate": "2020-02-03",
        "enddate": "2020-05-03",
       "Name": "SUB-20426",
      "description": "XQYember 03, 2020 "
    }
  ]
}

您可以在这种情况下使用液体模板:

Using Liquid Templates in Azure API Management

Using Liquid templates with set body

或者您在出站部分使用新的 JObject 创建一个新主体