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

Commit 5999f82

Browse files
committed
Fix empty array with whitespace
1 parent 3d1c0bc commit 5999f82

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

src/ServiceStack.Text/Common/DeserializeListWithElements.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ public static string StripList(string value)
5959
if (string.IsNullOrEmpty(value))
6060
return null;
6161

62+
value = value.TrimEnd();
63+
6264
const int startQuotePos = 1;
6365
const int endQuotePos = 2;
6466
var ret = value[0] == JsWriter.ListStartChar

tests/ServiceStack.Text.Tests/JsonTests/JsonArrayObjectTests.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,5 +122,18 @@ public void Can_parse_custom_AuthResponse()
122122
response.PrintDump();
123123
}
124124
}
125+
126+
class Test
127+
{
128+
public string Value { get; set; }
129+
}
130+
131+
[Test]
132+
public void Can_deserialize_empty_array_with_whitespace()
133+
{
134+
const string data = "[]\n";
135+
var result = data.FromJson<Test[]>();
136+
Assert.That(result.Length, Is.EqualTo(0));
137+
}
125138
}
126139
}

0 commit comments

Comments
 (0)