title: GSON exceptions - print field names that give errors when serialize a Nan
body: <p>I'm using Gson, ran into a problem serializing an object:</p>
  
  <pre><code>java.lang.IllegalArgumentException: NaN is not a valid double
      value as per JSON specification. To override this behavior, 
      use GsonBuilder.serializeSpecialFloatingPointValues() method.
      at com.google.gson.Gson.checkValidFloatingPoint(Gson.java:296)
      ...
  </code></pre>
  
  <p>Is there a way to have Gson print the class name/field name it is having a problem with? I can use the <code>serializeSpecialFloatingPointValues()</code> method as suggested, but ideally I'd like to understand where my objects have a NaN.</p>
  
  <p>-------- Update ----------------</p>
  
  <p>After painstakingly stepping through this, I think the cause is an uninitiatlized double. My setup looks like this:</p>
  
  <pre><code>public class Foo {
      private double price;
  }
  
  String jsonFromNet = ...;
  Foo foo = Gson.fromJson(jsonFromNet);
  Gson.toJson(foo, Foo.class); &lt;-- throws the exception
  </code></pre>
  
  <p>The return json from my api is not including the attribute "price", so I guess the member variable "d" is left uninitialized. When I go to serialize it, gson throws the error.</p>
  
  <p>If I give "price" an explicit value before serialization, or it happens to be in the api json response, everything works fine.</p>
  
  <p>Also if I change "price" from a double to a float, it doesn't seem to mind the uninitialized state.</p>
  
  <p>I'll look into GsonBuilder.serializeSpecialFloatingPointValues() now, I just wonder how the double gets serialized in this state. I'd be ok with a default value of zero or something.</p>
  
  <p>Thanks</p>