-Added support for reading GUID strings as bytes in JsonTextReader

-Changed reading GUIDs as bytes to only support 00000000-0000-0000-0000-000000000000 format
This commit is contained in:
James Newton-King
2015-06-10 17:10:16 +12:00
parent 652d18746a
commit 9e29489e5a
5 changed files with 41 additions and 6 deletions
+5
View File
@@ -117,11 +117,16 @@ namespace Newtonsoft.Json
if (_readType == ReadType.ReadAsBytes)
{
Guid g;
byte[] data;
if (_stringReference.Length == 0)
{
data = new byte[0];
}
else if (_stringReference.Length == 36 && ConvertUtils.TryConvertGuid(_stringReference.ToString(), out g))
{
data = g.ToByteArray();
}
else
{
data = Convert.FromBase64CharArray(_stringReference.Chars, _stringReference.StartIndex, _stringReference.Length);