現在、サードパーティのAPIと統合しています。サードパーティは、次の形式のjson文字列を受け入れています。
{
"test-specialism": null,
"salaryCollection": [
{
"id":
{
"jobtypeid": 1
},
"maxsalary": 564,
"minsalary": 123,
"salarycurrency": "GBP",
"salarytype": "A"
},
{
"id":
{
"jobtypeid": 2
},
"maxsalary": null,
"minsalary": null,
"salarycurrency": "GBP",
"salarytype": null
},
}],
}
そして、これが私のオブジェクトです:
public class Salary {
public double Minimum { get; set; }
public double Maximum { get; set; }
public PaymentFrequency Frequency { get; set; }
public double Step { get; set; }
public int JobTypeId { get; set; }
public SalarySetting() { }
}
public class Alert {
public string Specialism {get;set;}
public Salary Permanent { get; set; }
public Salary Temporary { get; set; }
public Salary Contract { get; set; }
}
ご覧のとおり、オブジェクト構造はJSON構造と非常に矛盾しています。オブジェクトをその指定されたjson文字列に変換する理想的な方法は何でしょうか?JSONPropertyを使用してプロパティをマップしようとしましたが、この場合はうまく機能しないようです。