【问题标题】:Azure API Set-body JSON to JSON covertAzure API Set-body JSON 到 JSON 转换
【发布时间】:2020-01-29 23:13:55
【问题描述】:

我得到的响应低于我需要将输入 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 格式,并在 out-bond 策略中使用 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 "
    }
  ]
}

【问题讨论】:

标签: azure azure-api-management azure-api-apps


【解决方案1】:

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

Using Liquid Templates in Azure API Management

Using Liquid templates with set body

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-03-22
    • 1970-01-01
    • 2019-12-29
    • 2012-10-15
    • 2017-01-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多