Reuven Bass
Reuven Bass

Reputation: 680

Json.Net: How to validate that there is one to one match between json and C# properties

MissingMemberHandling attributes instructs Json.Net to issue an error if json text contains property that is missing from C# class. I want the inverse behaviour as well. I want that Json.Net issues an error if there is a C# property that is missing from json text.

Upvotes: 1

Views: 224

Answers (1)

Reuven Bass
Reuven Bass

Reputation: 680

I little bit of source digging accomplished with documentation search showed

[JsonObject(ItemRequired = Required.Always)] 

Applying the above on class marks all of it fields required for de-serialization. As well, JsonObject attribute is inherited, what in my case is very helpful.

Upvotes: 1

Related Questions