@Override
  public JsonWriter value(Number value) throws IOException {
    if (value == null) {
      return nullValue();
    }
    if (value instanceof Integer) {
      generator.writeNumber(value.intValue());
    } else if (value instanceof Short) {
      generator.writeNumber(value.shortValue());
    } else if (value instanceof Long) {
      generator.writeNumber(value.longValue());
    } else if (value instanceof Float) {
      float f = value.floatValue();
      checkStrictNumber(f);
      generator.writeNumber(f);
    } else if (value instanceof BigInteger) {
      generator.writeNumber((BigInteger) value);
    } else if (value instanceof BigDecimal) {
      BigDecimal bd = (BigDecimal) value;
      checkStrictNumber(bd);
      generator.writeNumber(bd);
    } else {
      double d = value.doubleValue();
      checkStrictNumber(d);
      generator.writeNumber(d);
    }
    return this;
  }
{@link JsonWriter} implementation backed by Jackson's {@link JsonGenerator}.
Provides measurable JSON writing improvements over Gson's native implementation.
Error reporting is might differ, however.
gson/src/org/immutables/gson/stream/JsonGeneratorWriter.java