This project has moved and is read-only. For the latest updates, please go here.

Use of Required.AllowNull

Jan 27, 2010 at 1:38 AM

In the latest version the IsRequired property on JsonProperty was dropped for Required, which is a three-state boolean.

I assumed that Required = Required.AllowNull would enforce schema, but allow null values, but what it actually does is try to set the property value to null.

In other words if I want an Int64 property that can be null, but is required in the schema, then Json.NET will now try to make an Int64 null, causing an exception, rather than skipping it, which would result in a default value of 0.

How do we get back the old behavior?

Jan 28, 2010 at 7:28 AM

If the Int64 property can be null, shouldn't it be nullable in which case there isn't an issue?