Using ServiceStack v4.5.6.0, JSON array cannot be parsed correctly when leading space exists.
var test1 = "[{}, {}]";
var test1Result = JsonSerializer.DeserializeFromString<JsonArrayObjects>(test1);
Assert.AreEqual(2, test1Result.Count, "this is ok");
var test2 = " [{}, {}]";
var test2Result = JsonSerializer.DeserializeFromString<JsonArrayObjects>(test2);
Assert.AreEqual(2, test2result.Count, "this is not ok");
Is this the intended behavior of JSON arrays? I believed that JSON parsing should ignore whitespace except for inside string literals.
Note this code wont compile as there's no DeserializeFromJsonString
method.
But this issue is now fixed and available from v4.5.7+ that's now available on MyGet.