title: Decimal precision of zero when serializing doubles to JSON
body: <p>Consider the following JSON object:</p>
  
  <pre><code>{
      "value": 0   
  }
  </code></pre>
  
  <hr>
  
  <p>Now suppose I'm mapping this to a .NET type <code>Foo</code>:</p>
  
  <pre><code>class Foo
  {
      public double Value { get; set; }
  }
  </code></pre>
  
  <hr>
  
  <p>The type of <code>Foo.Value</code> is <code>double</code>, because <code>Value</code> isn't always an integer value.</p>
  
  <p>Using JSON.NET, this works beautifully:</p>
  
  <pre><code>Foo deserialized = JsonConvert.DeserializeObject&lt;Foo&gt;(json);
  </code></pre>
  
  <hr>
  
  <p>However, observe what happens when I try to convert the object back to its JSON representation:</p>
  
  <pre><code>string serialized = JsonConvert.SerializeObject(deserialized, Formatting.Indented);
  </code></pre>
  
  <p>Output:</p>
  
  <pre><code>{
    "Value": 0.0
  }
  </code></pre>
  
  <hr>
  
  <p>Notice the trailing zero? How do I get rid of it?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I suspect that the answer will be <em>write your own converter</em>. If it is, then that's fine and I guess I'll accept that as the answer. I'm just wondering if perhaps there exists an attribute that I don't know of that lets you specify the output format (or similar).</p>