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 a single opening bracket #1930

Open
adamgauthier opened this issue Nov 30, 2018 · 0 comments

Comments

@adamgauthier
Copy link

Steps to reproduce

// result is empty array
var result = JsonConvert.DeserializeObject("[");

// Newtonsoft.Json.JsonReaderException: 'Error reading JArray from JsonReader. Path '', line 1, position 1.'
var jarray = JArray.Parse("[");

Expected behavior

JsonConvert.DeserializeObject() throws an error on single opening bracket input.

Actual behavior

JsonConvert.DeserializeObject() successfully deserializes a single opening bracket input to an empty array.

Version

Tested with 12.0.1.

Related Issues

#1321

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

1 participant