title: Deserialize json string to a class using NewtonSoft.JSON
body: <p>This is my JSON string</p>
  
  <pre><code>{\"currentDateTime\":\"21-09-2014 17:48:00\",\"currentTime\":\"17:48:00.2360971\"}
  </code></pre>
  
  <p>I want to convert it to a class</p>
  
  <pre><code>public class CurrentDateTimeJson
      {
          public string currentDateTime { get; set; }
          public string currentTime { get; set; }
      }
  </code></pre>
  
  <p>I am using NewtonSoft.JSON to deserialize.</p>
  
  <p>Following is my code to deserialize</p>
  
  <pre><code>var a = JsonConvert.DeserializeObject&lt;CurrentDateTimeJson&gt;(jsonString);
  </code></pre>
  
  <p>I am getting following error</p>
  
  <p><strong>Error converting value "{"currentDateTime":"21-09-2014 17:51:56","currentTime":"17:51:56.9643252"}" to type 'CurrentDateTimeJson'.</strong></p>
  
  <p>Edit</p>
  
  <p>Code which produces the JSON</p>
  
  <pre><code> public string GetCurrentDateTimeJSON()
          {
              CurrentDateTime cdt = new CurrentDateTime()
              {
                  currentDateTime = DateTime.Now.ToString(),
                  currentTime = DateTime.Now.TimeOfDay.ToString()
              };
  
              string json = JsonConvert.SerializeObject(cdt);
              return json;
          }
  </code></pre>
  
  <p>Inner Exception</p>
  
  <p><strong>"Could not cast or convert from System.String to CurrentDateTimeJson."</strong></p>