-Fix issue when deserializing string to byte data

-Fix converting a JValue to a compatible type
-Allow JsonConverterAttribute to be added to interfaces/structs/enums
This commit is contained in:
JamesNK
2010-06-11 13:11:44 +00:00
parent f5ed7be283
commit 4a1c8d3a80
5 changed files with 50 additions and 3 deletions
@@ -214,8 +214,8 @@ namespace Newtonsoft.Json.Serialization
{
switch (reader.TokenType)
{
// populate a typed object or generic dictionary/array
// depending upon whether an objectType was supplied
// populate a typed object or generic dictionary/array
// depending upon whether an objectType was supplied
case JsonToken.StartObject:
return CreateObject(reader, objectType, contract, member, existingValue);
case JsonToken.StartArray:
@@ -233,6 +233,10 @@ namespace Newtonsoft.Json.Serialization
ReflectionUtils.IsNullableType(objectType))
return null;
// string that needs to be returned as a byte array should be base 64 decoded
if (objectType == typeof(byte[]))
return Convert.FromBase64String((string)reader.Value);
return EnsureType(reader.Value, objectType);
case JsonToken.StartConstructor:
case JsonToken.EndConstructor: