-Improved deserialization performance

-Added ISerializable support
-Changed dictionary serialization to fall back to ToString for keys
-Changed schema generator to use JsonContracts to determine schema information
-Fixed schema validation bugs when schema has no properties
-Fixed not marking dictionary and array schemas as nullable
-Fixed serializing generic dictionary that doesn't implement IDictionary
This commit is contained in:
JamesNK
2010-02-04 09:18:53 +00:00
parent 4dd8a2f6b8
commit 35cd765fd7
20 changed files with 943 additions and 137 deletions
+4 -4
View File
@@ -70,9 +70,9 @@ namespace Newtonsoft.Json
_schema = schema;
if (_schema != null && _schema.Properties != null)
{
_requiredProperties = GetRequiredProperties(_schema).Distinct().ToDictionary(p => p, p => false);
}
else
_requiredProperties = new Dictionary<string, bool>();
}
private IEnumerable<string> GetRequiredProperties(JsonSchemaModel schema)
@@ -178,7 +178,7 @@ namespace Newtonsoft.Json
throw new Exception("CurrentPropertyName has not been set on scope.");
JsonSchemaModel propertySchema;
if (CurrentSchema.Properties.TryGetValue(_currentScope.CurrentPropertyName, out propertySchema))
if (CurrentSchema.Properties != null && CurrentSchema.Properties.TryGetValue(_currentScope.CurrentPropertyName, out propertySchema))
return propertySchema;
return (CurrentSchema.AllowAdditionalProperties) ? CurrentSchema.AdditionalProperties : null;
@@ -552,7 +552,7 @@ namespace Newtonsoft.Json
if (_currentScope.RequiredProperties.ContainsKey(propertyName))
_currentScope.RequiredProperties[propertyName] = true;
if (!schema.Properties.ContainsKey(propertyName))
if (schema.Properties != null && !schema.Properties.ContainsKey(propertyName))
{
IList<string> definedProperties = schema.Properties.Select(p => p.Key).ToList();