What could be the reason for the following code to suddenly be throwing an error after upgrading the JSON.NET library to v10:
var name = json.Value<string>("Name"); // Error: Object must implement IConvertible
The error goes away if I change the line to indexer syntax:
var name = (string)json["Name"];
The puzzling bit is that the former line used to work perfectly fine with v6 of the library, but fails after upgrading to v10.
I'm also detecting a different behavior of null comparisons, which I also suspect is caused by the upgrade:
if (json["Name"] != null)
{
// I find myself in here because JTokenType.Null was unexpectedly returned above.
// This wasn't the case in v6!
}
Was there a breaking change somewhere between v6 and v10 of Newtonsoft.Json library? If not, what else could be causing my problems (especially the first one)?