title: Deserializing Noda Time's LocalDateTime with JSON.NET
body: <p>I'm trying to use Json.NET to serialize some Noda Time values and having trouble. Serialization is simple enough:</p>
  
  <pre><code>LocalDateTime dt = ... // Assigned elsewhere
  LocalDateTimePattern isoDateTimePattern = LocalDateTimePattern.GeneralIsoPattern;
  JObject root = new JObject();
  root.Add("time", isoDateTimePattern.Format(dt));
  
  // Serialize other elements
  
  using (var sw = new StreamWriter(stream)) {
      serializer.Serialize(sw, root);
  }
  </code></pre>
  
  <p>But deserialization is problematic. Json.NET seems to recognize the ISO-formatted date and time from above
  and automatically convert it into a DateTime object, which is not what I want.</p>
  
  <pre><code>using (var sr = new StreamReader(stream)) {
          using (var jr = new JsonTextReader(sr)) {
              var root = serializer.Deserialize&lt;JObject&gt;(jr);
  
              // Deserialize other elements
  
              var time = root.GetValue("time"); // time.Type is JTokenType.Date
              string timeStr = time.Value&lt;string&gt;(); // Is "01/10/2014 10:37:32"
  
              // Kaboom. String is not in the right format (see above comment)
              var parsedTime = isoDateTimePattern.Parse(time.Value&lt;string&gt;());
          }
  }
  </code></pre>
  
  <p>From the fact that <code>timeStr</code> comes out as a US-formatted date and time, I would guess that <code>time.Value&lt;string&gt;()</code>
  just calls <code>ToString</code> on some internal <code>DateTime</code> object that Json.NET has already parsed.
  I could do something like</p>
  
  <pre><code>var cdt = time.Value&lt;DateTime&gt;();
  LocalDateTime ldt = new LocalDateTime(cdt.Year, cdt.Month, cdt.Day, cdt.Hour, cdt.Minute);
  </code></pre>
  
  <p>but that's convoluted and means Json.NET is performing unneeded conversions.</p>
  
  <p>Is there any way to just get the raw string value of a JSON value?</p>