Partially deserialize using JSON.NET, keeping some fields unprocessed

I have such a document

{
    "Field1": 1,
    "Field2": 2,
    "Field3": {
        Type: "TheMotherLoad"
    }
}

What I want to convert to this class, but keeping field 3 is "raw / as-is".

public class Fields {
    public int Field1 { get; set; }
    public int Field2 { get; set; }
    public string Field3 { get; set; }
}

The result should be

Field1 = 1, 
Field2 = 2, 
Field3 = "{ Type: "TheMotherLoad" }"

Maybe with Json.NET?

+5
source share
1 answer

Field3 may be a JObject. When you need JSON, just call Field3.ToString ()

+7
source

All Articles