У меня есть объект json, который нужно десериализовать, я использую Json.NET для выполнения этих операций.
, когда это простой объект,это довольно легко сделать, но я не могу понять, как десериализовать эту строку
json
{
"aspsp-list":
[
{
"id":"424250495054504C",
"bic":"BBPIPTPL",
"bank-code":"0010",
"aspsp-cde":"BBPI",
"name":"BANCO BPI, SA",
"logoLocation":"../img/corporate/theBank.jpg",
"api-list":[{
"consents":["BBPI/v1/consents"],
"payments":["BBPI/v1/payments"],
"accounts":["BBPI/v1/accounts"],
"funds-confirmations":["BBPI/v1/funds-confirmations"]
}]
},
{
"id":"544F54415054504C",
"bic":"TOTAPTPL",
"bank-code":"0018",
"aspsp-cde":"BST",
"name":"BANCO SANTANDER TOTTA, SA",
"logoLocation":"../img/openBank.svc",
"api-list":[{
"consents":["BBPI/v1/consents"],
"payments":["BBPI/v1/payments"],
"accounts":["BBPI/v1/accounts"],
"funds-confirmations":["BST/v1/funds-confirmations"]
}]
}
]
}
Теперь код, который у меня пока есть:
internal class AspspListResponseResource
{
// Report with the list of supported ASPSPs. Each ASPSP will include the list of available API endpoints and the logo.
[JsonProperty(PropertyName = "aspsp-list")]
public AspspList[] AspspList { get; set; }
public AspspListResponseResource() { /* Empty constructor to create the object */ }
public AspspListResponseResource(string jsonString)
{
//var alrr = JsonConvert.DeserializeObject<AspspListResponseResource>(jsonString);
JObject jObject = JObject.Parse(jsonString);
JToken jUser = jObject["aspsp-list"];
// The root object here is coming with certain fields as null, such as 'aspsp-cde', 'bank-code' and 'api-list'
AspspListResponseResource root = JsonConvert.DeserializeObject<AspspListResponseResource>(jsonString);
}
}
internal class Aspsp
{
// ASPSP Id
[JsonProperty(PropertyName = "id")]
public string Id { get; set; } = "";
// Bank Identifier Code
[JsonProperty(PropertyName = "bic")]
public string Bic { get; set; } = "";
// IBAN Bank Identifier
[JsonProperty(PropertyName = "bank-code")]
public string BankCode { get; set; } = "";
// ASPSP Code to use in the endpoint
[JsonProperty(PropertyName = "aspsp-cde")]
public string AspspCde { get; set; } = "";
// Institution name
[JsonProperty(PropertyName = "name")]
public string Name { get; set; } = "";
// Bank logo location
[JsonProperty(PropertyName = "logoLocation")]
public string LogoLocation { get; set; } = "";
// Bank Supported API List
[JsonProperty(PropertyName = "api-list")]
public ApiLink[] ApiList { get; set; }
}
internal class ApiLink
{
// Consents Link List
[JsonProperty(PropertyName = "consents")]
public string[] Consents { get; set; } = { "" };
// Payments Link List
[JsonProperty(PropertyName = "payments")]
public string[] Payments { get; set; } = { "" };
// Accounts Link List
[JsonProperty(PropertyName = "accounts")]
public string[] Accounts { get; set; } = { "" };
// Balances Link List
[JsonProperty(PropertyName = "balances")]
public string[] Balances { get; set; } = { "" };
// Transaction Link List
[JsonProperty(PropertyName = "transaction")]
public string[] Transaction { get; set; } = { "" };
// Funds-Confirmations Link List
[JsonProperty(PropertyName = "funds-confirmations")]
public string[] FundsConfirmations { get; set; } = { "" };
}
Сумма значений десериализованного объекта равна нулю, даже если у jsonString определенно есть данные.
Как мне поступить здесь?