0

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; }
}
2

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.