-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
+21
View File
@@ -101,6 +101,7 @@ namespace Newtonsoft.Json
Array,
ConstructorStart,
Constructor,
Bytes,
Closed,
Error
}
@@ -578,6 +579,7 @@ namespace Newtonsoft.Json
case JsonToken.Null:
case JsonToken.Undefined:
case JsonToken.Date:
case JsonToken.Bytes:
// a value is being written
token = 7;
break;
@@ -780,6 +782,7 @@ namespace Newtonsoft.Json
AutoComplete(JsonToken.Date);
}
#if !PocketPC && !NET20
/// <summary>
/// Writes a <see cref="DateTimeOffset"/> value.
/// </summary>
@@ -788,6 +791,7 @@ namespace Newtonsoft.Json
{
AutoComplete(JsonToken.Date);
}
#endif
/// <summary>
/// Writes a <see cref="Nullable{Int32}"/> value.
@@ -957,6 +961,7 @@ namespace Newtonsoft.Json
WriteValue(value.Value);
}
#if !PocketPC && !NET20
/// <summary>
/// Writes a <see cref="Nullable{DateTimeOffset}"/> value.
/// </summary>
@@ -968,6 +973,15 @@ namespace Newtonsoft.Json
else
WriteValue(value.Value);
}
#endif
public virtual void WriteValue(byte[] value)
{
if (value == null)
WriteNull();
else
AutoComplete(JsonToken.Bytes);
}
/// <summary>
/// Writes a <see cref="Object"/> value.
@@ -1037,11 +1051,18 @@ namespace Newtonsoft.Json
return;
}
}
#if !PocketPC && !NET20
else if (value is DateTimeOffset)
{
WriteValue((DateTimeOffset)value);
return;
}
#endif
else if (value is byte[])
{
WriteValue((byte[])value);
return;
}
throw new ArgumentException("Unsupported type: {0}. Use the JsonSerializer class to get the object's JSON representation.".FormatWith(CultureInfo.InvariantCulture, value.GetType()));
}