I have the following JSON text:
{
"personAFirstName": "John",
"personALastName": "Smith",
"personBFirstName": "Alexander",
"personBLastName": "Hamilton"
}
And want to deserialize it to the following object shape:
{
"a": {
"firstName": "John",
"lastName": "Smith"
},
"b": {
"firstName": "Alexander",
"lastName": "Hamilton"
}
}
Is there a simple way using Newtonsoft.Json Attributes or do I need to do something more complicated than that on the class specification?
class Relationship
{
Person a { get; set; }
Person b { get; set; }
}
class Person
{
string firstName { get; set; }
string lastName { get; set; }
}
JsonConverterlike the one from Deserialize JSON object into nested C# object.