You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
EDIT: adding CheckAdditionalContent = true in the settings make the PopulateObject throw for this case, but it's still confusing that both methods won't have the same default behavior
Source/destination types
classTest{publicinttest;}
Source/destination JSON
"{\"test\":1}gg"
Expected behavior
Should throw JsonReaderException
Actual behavior
Will deserialize the proper value. (Test.test == 1)
Steps to reproduce
// here is a test case that fails in the last step[Test]publicvoidPopulateObjectInvalidJson(){
Assert.Throws(typeof(JsonReaderException),()=>{varo= JsonConvert.DeserializeObject<Test>("{\"test\":1}invalidtrailingchar");});// will pass
Assert.Throws(typeof(JsonReaderException),()=>{varo=new Test(){test=0}; JsonConvert.PopulateObject("{\"test\":1}invalidtrailingchar", o);});// will fail here}classTest{publicinttest;}
The text was updated successfully, but these errors were encountered:
abhiroop43
added a commit
to abhiroop43/Newtonsoft.Json
that referenced
this issue
Dec 29, 2023
EDIT: adding
CheckAdditionalContent = true
in the settings make the PopulateObject throw for this case, but it's still confusing that both methods won't have the same default behaviorSource/destination types
Source/destination JSON
"{\"test\":1}gg"
Expected behavior
Should throw JsonReaderException
Actual behavior
Will deserialize the proper value. (Test.test == 1)
Steps to reproduce
The text was updated successfully, but these errors were encountered: