How to check if JToken is null

Hi,

I’m working with Json and I have a variable FieldValue of type JToken. I want to check if it is null.
I’ve tried using the following

  • FieldValue.Type.Equals(JTokenType.Null)
  • FieldValue.Type.Equals(JTokenType.Undefined)
  • FieldValue.Equals(Newtonsoft.Json.JsonToken.Null)

But all of them are giving me this error Object reference not set to an instance of an object
error

Any help will be much appreciated.
Thanks in Advance :slight_smile:

Have you tested with

FieldValue Is Nothing

@ptrobot
It worked like a Charm. I don’t know why this didn’t cross my mind :smiley:
Thank you so much :slight_smile:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.