Checking for empty or null JToken in a JObject

后端 未结 5 1103
忘了有多久
忘了有多久 2020-12-04 17:23

I have the following...

JArray clients = (JArray)clientsParsed[\"objects\"];

foreach (JObject item in clients.Children())
{
    // etc.. SQL params stuff...         


        
5条回答
  •  温柔的废话
    2020-12-04 17:58

    You can proceed as follows to check whether a JToken Value is null

    JToken token = jObject["key"];
    
    if(token.Type == JTokenType.Null)
    {
        // Do your logic
    }
    

提交回复
热议问题