Skip to content
This repository was archived by the owner on Dec 24, 2022. It is now read-only.

Commit c558343

Browse files
committed
Make alt ExtractType whitespace insensitive
1 parent 7a3103c commit c558343

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

src/ServiceStack.Text/Common/DeserializeType.cs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ public static object ObjectStringToType(string strType)
7272

7373
public static Type ExtractType(string strType)
7474
{
75-
var typeAttrInObject = Serializer.TypeAttrInObject;
7675
if (strType == null || strType.Length <= 1) return null;
7776

7877
var hasWhitespace = JsonUtils.WhiteSpaceChars.Contains(strType[1]);
@@ -83,6 +82,7 @@ public static Type ExtractType(string strType)
8382
strType = "{" + strType.Substring(pos);
8483
}
8584

85+
var typeAttrInObject = Serializer.TypeAttrInObject;
8686
if (strType.Length > typeAttrInObject.Length
8787
&& strType.Substring(0, typeAttrInObject.Length) == typeAttrInObject)
8888
{
@@ -234,10 +234,18 @@ internal class TypeAccessor
234234

235235
public static Type ExtractType(ITypeSerializer Serializer, string strType)
236236
{
237-
var typeAttrInObject = Serializer.TypeAttrInObject;
237+
if (strType == null || strType.Length <= 1) return null;
238+
239+
var hasWhitespace = JsonUtils.WhiteSpaceChars.Contains(strType[1]);
240+
if (hasWhitespace)
241+
{
242+
var pos = strType.IndexOf('"');
243+
if (pos >= 0)
244+
strType = "{" + strType.Substring(pos);
245+
}
238246

239-
if (strType != null
240-
&& strType.Length > typeAttrInObject.Length
247+
var typeAttrInObject = Serializer.TypeAttrInObject;
248+
if (strType.Length > typeAttrInObject.Length
241249
&& strType.Substring(0, typeAttrInObject.Length) == typeAttrInObject)
242250
{
243251
var propIndex = typeAttrInObject.Length;

0 commit comments

Comments
 (0)