deserialize a invalid json format(with number beginning) string unexpected
Opened this issue · 1 comments
lostsnow commented
Reproduce code:
string s = "2a";
Object x = SimpleJson.DeserializeObject(s);
Expected result:
throw Invalid JSON string Exception
Actual result:
2
prabirshrestha commented
good catch. can u send a PR with failing unit test and fix if possible.
Seems like var s1 = "{\"a\":2a}";
and var s2 = "[2a]";
throws the json exception but not var s = "2a";
.
The fix can be added to this line.
simple-json/src/SimpleJson/SimpleJson.cs
Line 548 in e2528f3
If the index
is less then charArray.Length
means we haven't completed parsing the json string and should set obj
to null and return false.
Seems like var s = "\"a\"2";
also doesn't throw json exception.