Reduce discrepancies between FlatbufferToJson versions

This:
* Causes NaNs to always be printed as "nan" or "-nan".
* Makes whitespace printing more consistent.

Additionally:
* Adds several TODOs regarding remaining discrepancies.
* Swaps an argument type to a const char * to improve overload
  resolution.

Change-Id: Ibcd46d5d59ca607f96736c61d3159136a43c75ce
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/flatbuffer_introspection.cc b/aos/flatbuffer_introspection.cc
index 4dd7f2a..163c281 100644
--- a/aos/flatbuffer_introspection.cc
+++ b/aos/flatbuffer_introspection.cc
@@ -61,7 +61,7 @@
 void FloatToString(double val, reflection::BaseType type,
                    FastStringBuilder *out) {
   if (std::isnan(val)) {
-    out->Append("null");
+    out->Append(std::signbit(val) ? "-nan" : "nan");
     return;
   }
   switch (type) {
@@ -228,6 +228,9 @@
         }
 
         out->AppendChar('[');
+        if (!wrap) {
+          out->AppendChar(' ');
+        }
         for (flatbuffers::uoffset_t i = 0; i < vector->size(); ++i) {
           if (i != 0) {
             if (wrap) {
@@ -271,6 +274,8 @@
         }
         if (wrap) {
           AddWrapping(out, tree_depth);
+        } else {
+          out->AppendChar(' ');
         }
         out->AppendChar(']');
       } else {
@@ -327,6 +332,9 @@
   }
 
   out->AppendChar('{');
+  if (!wrap) {
+    out->AppendChar(' ');
+  }
   for (const reflection::Field *field : *obj->fields()) {
     // Check whether this object has the field populated (even for structs,
     // which should have all fields populated)
@@ -355,6 +363,8 @@
 
   if (wrap) {
     AddWrapping(out, tree_depth);
+  } else {
+    out->AppendChar(' ');
   }
 
   out->AppendChar('}');