diff --git a/Src/Newtonsoft.Json/Utilities/ConvertUtils.cs b/Src/Newtonsoft.Json/Utilities/ConvertUtils.cs index 22ec8fcc..0961fb85 100644 --- a/Src/Newtonsoft.Json/Utilities/ConvertUtils.cs +++ b/Src/Newtonsoft.Json/Utilities/ConvertUtils.cs @@ -30,6 +30,7 @@ using System.ComponentModel; #if !(NET20 || NET35 || PORTABLE40 || PORTABLE) using System.Numerics; #endif +using System.Text; using Newtonsoft.Json.Serialization; using System.Reflection; #if NET20 @@ -395,6 +396,8 @@ namespace Newtonsoft.Json.Utilities return new Uri((string)initialValue, UriKind.RelativeOrAbsolute); if (targetType == typeof(TimeSpan)) return ParseTimeSpan((string)initialValue); + if (targetType == typeof (byte[])) + return ParseBytes((string) initialValue); if (typeof(Type).IsAssignableFrom(targetType)) return Type.GetType((string)initialValue, true); } @@ -438,6 +441,12 @@ namespace Newtonsoft.Json.Utilities throw new InvalidOperationException("Can not convert from {0} to {1}.".FormatWith(CultureInfo.InvariantCulture, initialType, targetType)); } + + private static object ParseBytes(string initialValue) + { + return System.Convert.FromBase64String(initialValue); + } + #endregion #region TryConvert