-Added reading and writing binary JSON (BSON) support - work in progress

-Added BsonReader, BsonWriter
-Added support for reading and writing byte arrays to JsonReader, JsonWriter and LINQ to JSON classes
-Added ReadAsBytes to JsonReader
-Changed Silverlight build serializer to look for a TypeConverter
-Changed .NET build to not rely on System.ComponentModel.DataAnnotations assembly to support .NET 4.0 client profile
-Remove DateTimeOffset stand-in from Compact Framework build
-Fixed .NET 2.0 build to run on environments without .NET 2.0 SP1
-Fixed deserialization to always use a new value created from a JsonConverter
-Fixed XmlNodeConverter to support converting comments in JSON
This commit is contained in:
JamesNK
2009-12-06 23:10:14 +00:00
parent 7d845d1f13
commit f1a9993723
59 changed files with 1952 additions and 697 deletions
+19 -7
View File
@@ -304,6 +304,14 @@ namespace Newtonsoft.Json
}
}
public override byte[] ReadAsBytes()
{
byte[] data = _reader.ReadAsBytes();
ValidateCurrentToken();
return data;
}
/// <summary>
/// Reads the next JSON token from the stream.
/// </summary>
@@ -318,7 +326,13 @@ namespace Newtonsoft.Json
if (_reader.TokenType == JsonToken.Comment)
return true;
// first time Read has been called. build model
ValidateCurrentToken();
return true;
}
private void ValidateCurrentToken()
{
// first time validate has been called. build model
if (_model == null)
{
JsonSchemaModelBuilder builder = new JsonSchemaModelBuilder();
@@ -330,15 +344,15 @@ namespace Newtonsoft.Json
case JsonToken.StartObject:
ProcessValue();
JsonSchemaModel objectSchema = (ValidateObject(CurrentMemberSchema))
? CurrentMemberSchema
: null;
? CurrentMemberSchema
: null;
Push(new SchemaScope(JTokenType.Object, objectSchema));
break;
case JsonToken.StartArray:
ProcessValue();
JsonSchemaModel arraySchema = (ValidateArray(CurrentMemberSchema))
? CurrentMemberSchema
: null;
? CurrentMemberSchema
: null;
Push(new SchemaScope(JTokenType.Array, arraySchema));
break;
case JsonToken.StartConstructor:
@@ -387,8 +401,6 @@ namespace Newtonsoft.Json
default:
throw new ArgumentOutOfRangeException();
}
return true;
}
private void ValidateEndObject(JsonSchemaModel schema)