using Newtonsoft.Json.Linq;
public static void Main()
string json = @"{ ""nullProperty"": null, ""stringProperty"": ""hello world"" }";
dynamic dynamicObject = JsonConvert.DeserializeObject(json);
DumpProperty(dynamicObject, "stringProperty");
DumpProperty(dynamicObject, "nullProperty");
DumpProperty(dynamicObject, "nonExistentProperty");
private static void DumpProperty(dynamic dynamicObject, string propertyName)
JObject jo = (JObject)dynamicObject;
JToken token = jo[propertyName];
Console.Write(propertyName + " exists and is a " + token.GetType().Name);
if (token.Type == JTokenType.Null)
Console.WriteLine(" with a value of null.");
Console.WriteLine(" with a value of \"" + token.ToString() + "\".");
Console.WriteLine(propertyName + " does not exist.");