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

JsonConvert.DeserializeObject doesn't throw an exception for an invalid array #1321

Closed
Francisco-Gamino opened this issue May 22, 2017 · 1 comment

Comments

@Francisco-Gamino
Copy link

Hi,

When calling JsonConvert.DeserializeObject with an invalid array as input an exception should be thrown, bu this is not the case. However, JArray.Parse does throw an exception. Is there a reason why does but not the other?

Thanks,
Francisco

Steps to reproduce

obj = JsonConvert.DeserializeObject('["1",', new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.None, MaxDepth = 1024 });

Expected behavior

A JsonException is thrown since '["1",' is not a valid array.

Actual behavior

No exception is thrown

@JamesNK
Copy link
Owner

JamesNK commented May 28, 2017

Thanks for the detailed bug report. Fixed 1a0ae2a

@JamesNK JamesNK closed this as completed May 28, 2017
TravisEz13 pushed a commit to PowerShell/PowerShell that referenced this issue Dec 3, 2018
…8377)

This is a follow up to reverted PR #8346. I removed a workaround that was used to avoid [a Newtonsoft.Json bug](JamesNK/Newtonsoft.Json#1321) that caused some incomplete json array input to successfully be deserialized.

This bug being fixed, I thought the workaround was unnecessary, but after the merge some feature tests started to fail (which I did not run prior to merging).

It was discovered that the workaround is still needed because while the first Newtonsoft.Json bug was fixed, some cases of incomplete json array input still behave unexpectedly, namely json input `[`. 

This PR is just to update the comment explaining the workaround so it links to the newly created issue [here](JamesNK/Newtonsoft.Json#1930).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants