If I have a JSON Schema that specifies a default value for a property, like
{
"type" : "object",
"properties" : {
"foo" : { "type" : "string" },
"bar" : { "type" : "string", "default" : "some text" }
}
}
...and a JSON string like
{
"foo" : "lorem ipsum"
}
...how can I deserialize that JSON string so that bar
is set to "some text" (the default value) instead of null?
I traced the references in the Json.NET source code, and the default attribute is apparently parsed, but not used for anything. So, the answer to my own question is: You can't use it in the current Json.NET version.