Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
lostsnow opened this issue Jan 13, 2014 · 1 comment
Labels

Comments

@lostsnow
Copy link

Reproduce code:

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

Expected result:

throw Invalid JSON string Exception

Actual result:

2

@prabirshrestha
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants