title: Possible to look for Key that does not exist in Json.net
body: <p>I got a couple different formats that come in but I can't figure out how to handle them all because when I try to find by key json.net crashes. I was hoping it would just return null.</p>
  
  <pre><code>foreach (var item in jsonObj)
  {
      var msg = item.Value["Msg"];
      if (msg != null)
      {
         txtErrors.Text += msg + Environment.NewLine;
      }
  }
  </code></pre>
  
  <p>// format one</p>
  
  <pre><code>{[UserNotFound, {
    "SeverityType": 3,
    "ValidationType": 2,
    "Msg": "Email Not Found"
  }]}
  </code></pre>
  
  <p>my code works.</p>
  
  <p>// format 2 (came because I did not catch an exception on serverside)</p>
  
  <pre><code>{
    "Message": "An error has occurred.",
    "ExceptionMessage": "Object reference not set to an instance of an object.",
    "ExceptionType": "System.NullReferenceException",
    "StackTrace": "  "
  }
  </code></pre>
  
  <p>I can of course fix this and catch the exception. However if I ever forget again, I rather not have it crash on the client as well. So I would love to just print out the "message" but I don't get how to do it so it does not crash on <code>var msg = item.Value["Msg"];</code></p>
  
  <p>The error I get when it tries to do var <code>msg = item.Value["Msg"];</code></p>
  
  <pre><code>System.InvalidOperationException was unhandled
    Message=Cannot access child value on Newtonsoft.Json.Linq.JValue.
    StackTrace:
         at Newtonsoft.Json.Linq.JToken.get_Item(Object key)
         at Fitness.WindowsPhone7.UI.MainPage.&lt;btnSignIn_Click&gt;b__0(IRestResponse response)
         at RestSharp.RestClientExtensions.&lt;&gt;c__DisplayClass1.&lt;ExecuteAsync&gt;b__0(IRestResponse response, RestRequestAsyncHandle handle)
         at RestSharp.RestClient.ProcessResponse(IRestRequest request, HttpResponse httpResponse, RestRequestAsyncHandle asyncHandle, Action`2 callback)
         at RestSharp.RestClient.&lt;&gt;c__DisplayClass3.&lt;ExecuteAsync&gt;b__0(HttpResponse r)
         at RestSharp.RestClient.&lt;&gt;c__DisplayClass5.&lt;&gt;c__DisplayClass7.&lt;ExecuteAsync&gt;b__2(Object s)
         at System.Reflection.RuntimeMethodInfo.InternalInvoke(RuntimeMethodInfo rtmi, Object obj, BindingFlags invokeAttr, Binder binder, Object parameters, CultureInfo culture, Boolean isBinderDefault, Assembly caller, Boolean verifyAccess, StackCrawlMark&amp; stackMark)
         at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, StackCrawlMark&amp; stackMark)
         at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
         at System.Delegate.DynamicInvokeOne(Object[] args)
         at System.MulticastDelegate.DynamicInvokeImpl(Object[] args)
         at System.Delegate.DynamicInvoke(Object[] args)
         at System.Windows.Threading.DispatcherOperation.Invoke()
         at System.Windows.Threading.Dispatcher.Dispatch(DispatcherPriority priority)
         at System.Windows.Threading.Dispatcher.OnInvoke(Object context)
         at System.Windows.Hosting.CallbackCookie.Invoke(Object[] args)
         at System.Windows.Hosting.DelegateWrapper.InternalInvoke(Object[] args)
         at System.Windows.RuntimeHost.ManagedHost.InvokeDelegate(IntPtr pHandle, Int32 nParamCount, ScriptParam[] pParams, ScriptParam&amp; pResult)
  </code></pre>