向 REST API 请求添加新标签
Adding a new tag to the REST API Request
我正在处理一项任务,将新标签添加到 JSON 请求中,我们将进行标注。请求如下。
{
"Version": "1.0",
"RequestingSystemName": "SFORCECS",
"InsuredInformation": {
"Zipcode": "12335",
"StateProvinceCode": "CA",
"PhoneNumber": "(111) 111-2222",
"MiddleName": null,
"LastName": "ABC",
"FirstName": "DEF",
"City": "PLACEWI",
"BirthDate": "1950-01-01",
"AddressLine3": null,
"AddressLine2": null,
"AddressLine1": "111 123 Drive"
},
"BeneficiaryList": [
{
"RelationShipEnum": "Nephew",
"Relationship": 18,
"PrimaryIndicator": 0,
"Percentage": null,
"FullName": "XYZ DEQ"
},
{
"RelationShipEnum": "Niece",
"Relationship": 20,
"PrimaryIndicator": 0,
"Percentage": null,
"FullName": "DEQ XYZ"
}
],
"ApplicationInformation": {
"SignedDateTime": "2010-01-01T01:01:01.000Z",
"ProductIdentifier": "1",
"MarketingSequenceNumber": "11111111111",
"EmailAddress": null,
"ContractNumber": "1111111",
"BasicAmount": "1000",
"AgentID": "12345"
}
}
现在,我的任务是更改受益人信息请求。应该如下图。
"BeneficiaryList": {"Beneficiary":[
{
"RelationShipEnum": "Nephew",
"Relationship": 18,
"PrimaryIndicator": 0,
"Percentage": null,
"FullName": "XYZ DEQ"
},
{
"RelationShipEnum": "Niece",
"Relationship": 20,
"PrimaryIndicator": 0,
"Percentage": null,
"FullName": "DEQ XYZ"
}
]},
有人可以帮忙吗?生成受益人信息请求的顶点class如下。
public class ReqBasic{
public class Beneficiary{
public Beneficiary(){}
public Beneficiary(String FullName, Integer PrimaryIndicator, Integer Percentage, Integer Relationship){
this.FullName = FullName;
this.PrimaryIndicator = PrimaryIndicator;
this.Percentage = Percentage;
this.Relationship = Relationship;
}
public Beneficiary(String FullName, String PrimaryIndicator, Integer Percentage, String Relationship){
this.FullName = FullName;
this.setPrimaryIndicatorStr(PrimaryIndicator);
this.Percentage = Percentage;
this.setRelationshipStr(Relationship);
}
}
}
我不确定我需要做哪些更改才能在 BeneficiaryList 下添加 beneficiary: 标签。有人可以帮忙吗?
您共享的代码没有您需要的内容,但在请求的某个地方 class 您应该有一个名为 BeneficiaryList 的变量,它看起来像
List< Beneficiary> BeneficiaryList; //or = new List<Beneficiary>(); or Beneficiary[] depending on the coding style
您需要创建一个新的 class 名为受益人(或任何您想要的),其中包含受益人列表
public class Beneficiaries{
List< Beneficiary> Beneficiary = new List<Beneficiary>();
public Beneficiaries(List<Beneficiary> beneficiaries){
Beneficiary.addAll(beneficiaries);
}
}
然后在您的 class 中,请求集 BeneficiaryList 从受益人列表到新受益人 class
Beneficiaries BeneficiaryList = new Beneficiaries(beneficiaries);
显然,您的实施将取决于您的请求 class 的设置方式以及您添加受益人的方式,但您至少应该创建一个 add(...) 方法,这样您就不必更改太多代码
我正在处理一项任务,将新标签添加到 JSON 请求中,我们将进行标注。请求如下。
{
"Version": "1.0",
"RequestingSystemName": "SFORCECS",
"InsuredInformation": {
"Zipcode": "12335",
"StateProvinceCode": "CA",
"PhoneNumber": "(111) 111-2222",
"MiddleName": null,
"LastName": "ABC",
"FirstName": "DEF",
"City": "PLACEWI",
"BirthDate": "1950-01-01",
"AddressLine3": null,
"AddressLine2": null,
"AddressLine1": "111 123 Drive"
},
"BeneficiaryList": [
{
"RelationShipEnum": "Nephew",
"Relationship": 18,
"PrimaryIndicator": 0,
"Percentage": null,
"FullName": "XYZ DEQ"
},
{
"RelationShipEnum": "Niece",
"Relationship": 20,
"PrimaryIndicator": 0,
"Percentage": null,
"FullName": "DEQ XYZ"
}
],
"ApplicationInformation": {
"SignedDateTime": "2010-01-01T01:01:01.000Z",
"ProductIdentifier": "1",
"MarketingSequenceNumber": "11111111111",
"EmailAddress": null,
"ContractNumber": "1111111",
"BasicAmount": "1000",
"AgentID": "12345"
}
}
现在,我的任务是更改受益人信息请求。应该如下图。
"BeneficiaryList": {"Beneficiary":[
{
"RelationShipEnum": "Nephew",
"Relationship": 18,
"PrimaryIndicator": 0,
"Percentage": null,
"FullName": "XYZ DEQ"
},
{
"RelationShipEnum": "Niece",
"Relationship": 20,
"PrimaryIndicator": 0,
"Percentage": null,
"FullName": "DEQ XYZ"
}
]},
有人可以帮忙吗?生成受益人信息请求的顶点class如下。
public class ReqBasic{
public class Beneficiary{
public Beneficiary(){}
public Beneficiary(String FullName, Integer PrimaryIndicator, Integer Percentage, Integer Relationship){
this.FullName = FullName;
this.PrimaryIndicator = PrimaryIndicator;
this.Percentage = Percentage;
this.Relationship = Relationship;
}
public Beneficiary(String FullName, String PrimaryIndicator, Integer Percentage, String Relationship){
this.FullName = FullName;
this.setPrimaryIndicatorStr(PrimaryIndicator);
this.Percentage = Percentage;
this.setRelationshipStr(Relationship);
}
}
}
我不确定我需要做哪些更改才能在 BeneficiaryList 下添加 beneficiary: 标签。有人可以帮忙吗?
您共享的代码没有您需要的内容,但在请求的某个地方 class 您应该有一个名为 BeneficiaryList 的变量,它看起来像
List< Beneficiary> BeneficiaryList; //or = new List<Beneficiary>(); or Beneficiary[] depending on the coding style
您需要创建一个新的 class 名为受益人(或任何您想要的),其中包含受益人列表
public class Beneficiaries{
List< Beneficiary> Beneficiary = new List<Beneficiary>();
public Beneficiaries(List<Beneficiary> beneficiaries){
Beneficiary.addAll(beneficiaries);
}
}
然后在您的 class 中,请求集 BeneficiaryList 从受益人列表到新受益人 class
Beneficiaries BeneficiaryList = new Beneficiaries(beneficiaries);
显然,您的实施将取决于您的请求 class 的设置方式以及您添加受益人的方式,但您至少应该创建一个 add(...) 方法,这样您就不必更改太多代码