-Change BSON writer to write new binary subtype
-Fix BSON reader to read the old binary subtype correctly -Added JsonNet35BinaryCompadibility to BSON reader for incorrectly written BSON binary values -Changed JSON schema to use required flags instead of optional as defined in JSON schema spec 3.0 -Changed JSON schema to use divisibleBy instead of maxDecimals as defined in JSON schema spec 3.0 -Fixed detection of serialization specified flag properties -Updated to latest version of NuGet
This commit is contained in:
@@ -77,7 +77,7 @@ namespace Newtonsoft.Json
|
||||
|
||||
private IEnumerable<string> GetRequiredProperties(JsonSchemaModel schema)
|
||||
{
|
||||
return schema.Properties.Where(p => !p.Value.Optional).Select(p => p.Key);
|
||||
return schema.Properties.Where(p => p.Value.Required).Select(p => p.Key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -448,7 +448,7 @@ namespace Newtonsoft.Json
|
||||
requiredProperties.Where(kv => !kv.Value).Select(kv => kv.Key).ToList();
|
||||
|
||||
if (unmatchedRequiredProperties.Count > 0)
|
||||
RaiseError("Non-optional properties are missing from object: {0}.".FormatWith(CultureInfo.InvariantCulture, string.Join(", ", unmatchedRequiredProperties.ToArray())), schema);
|
||||
RaiseError("Required properties are missing from object: {0}.".FormatWith(CultureInfo.InvariantCulture, string.Join(", ", unmatchedRequiredProperties.ToArray())), schema);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -564,8 +564,15 @@ namespace Newtonsoft.Json
|
||||
if (schema.Minimum != null && value < schema.Minimum)
|
||||
RaiseError("Float {0} is less than minimum value of {1}.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.Minimum), schema);
|
||||
|
||||
if (schema.MaximumDecimals != null && MathUtils.GetDecimalPlaces(value) > schema.MaximumDecimals)
|
||||
RaiseError("Float {0} exceeds the maximum allowed number decimal places of {1}.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.MaximumDecimals), schema);
|
||||
if (schema.DivisibleBy != null && !IsZero(value % schema.DivisibleBy.Value))
|
||||
RaiseError("Float {0} is not evenly divisible by {1}.".FormatWith(CultureInfo.InvariantCulture, JsonConvert.ToString(value), schema.DivisibleBy), schema);
|
||||
}
|
||||
|
||||
private static bool IsZero(double value)
|
||||
{
|
||||
double epsilon = 2.2204460492503131e-016;
|
||||
|
||||
return Math.Abs(value) < 10.0 * epsilon;
|
||||
}
|
||||
|
||||
private void ValidatePropertyName(JsonSchemaModel schema)
|
||||
|
||||
Reference in New Issue
Block a user