code: private static void toJSONString(OutputAccessor out, Object value) {
  
          if (value == null) {
              out.write(NULL);
              return;
          }
  
          if (value instanceof String) {
              out.write((byte) '\"');
              writeUtf8(out, (String) value);
              out.write((byte) '\"');
              return;
          }
  
          if (value instanceof Double) {
              Double d = (Double) value;
              if (d.isNaN()) {
                  out.write((byte) '\"');
                  out.write(NaN);
                  out.write((byte) '\"');
              } else if (d.isInfinite()) {
                  out.write((byte) '\"');
                  if (d == Double.NEGATIVE_INFINITY) {
                      out.write('-');
  
                  }
                  out.write(Infinite);
                  out.write((byte) '\"');
              } else {
                  writeAscii(out, value.toString());
  
              }
              return;
          }
  
          if (value instanceof Float) {
              Float f = (Float) value;
              if (f.isNaN()) {
                  out.write((byte) '\"');
                  out.write(NaN);
                  out.write((byte) '\"');
              } else if (f.isInfinite()) {
                  out.write((byte) '\"');
                  if (f == Float.NEGATIVE_INFINITY) {
                      out.write('-');
  
                  }
                  out.write(Infinite);
                  out.write((byte) '\"');
              } else {
                  writeAscii(out, value.toString());
  
              }
              return;
          }
  
          if (value instanceof Number) {
              writeAscii(out, value.toString());
          }
  
          if (value instanceof Boolean) {
  
              if ((Boolean) value) {
                  out.write(TRUE);
              } else {
                  out.write(FALSE);
              }
          }
      }
docs: Convert an object to JSON text. Encode the value as UTF-8 text, or "null" if value is null or it's an NaN or an INF
  number.