facebook-csharp-sdk/simple-json

deserialize a invalid json format(with number beginning) string unexpected

Opened this issue · 1 comments

Reproduce code:

string s = "2a";
Object x = SimpleJson.DeserializeObject(s);

Expected result:

throw Invalid JSON string Exception

Actual result:

2

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.

obj = ParseValue(charArray, ref index, ref success);

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.