Im using C# and Json.NET and i want to convert a Json string with arrays to a single class object. I tried using JsonConvert.Populate with JsonProperty DataAnnotation, but didnt worked
Here is an example of what i tried
JSON String:
{
"name":"julian",
"card":{
"cardholder":{
"identification":{
"number":"32556188",
"type":"DNI"
},
"name":"John"
}
}
}
C# Class:
public class Payment
{
[JsonProperty("name")]
public string Name { get; set; }
[JsonProperty("card.cardholder.name")]
public string CardHolderName { get; set; }
[JsonProperty("card.cardholder.identification.number")]
public string CardHolderIdentificationNumber { get; set; }
}
Code of Conversion:
var jsonString = ObtainJSONString();
var _payment = new Payment();
JsonConvert.PopulateObject(jsonString, _payment);