Recently upgraded to Visual Studio 2017 and am facing a weird issue. I am not able to cast Netwonsoft.Json.Linq.JValue to a bool.
For instance, here is my object "actualObj" which contains a bool (shown in QuickWatch):
Now, when I cast it to a bool, which should have worked as per the docs, I get an invalid cast exception:
What should I be doing differently?
Try to cast the Value
property of the JValue
:
JValue jv = actualObject as JValue;
if(jv != null)
{
bool b = (bool)jv.Value;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With