问题
I have a document like this
{
"Field1": 1,
"Field2": 2,
"Field3": {
Type: "TheMotherLoad"
}
}
Which i want to convert into this class, but keeping field 3 "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" }"
Possible with Json.NET?
回答1:
Field3 could be a JObject. When you need JSON just call Field3.ToString()
来源:https://stackoverflow.com/questions/15828230/partially-deserialize-with-json-net-keeping-some-fields-raw