private void setNumberField(JsonParser jp, JSONToPdxMapper pih, String fieldName)
      throws IOException {
    NumberType nt = jp.getNumberType();

    switch (nt) {
      case BIG_DECIMAL:
        pih.addBigDecimalField(fieldName, jp.getDecimalValue());
        break;
      case BIG_INTEGER: {
        BigInteger bi = jp.getBigIntegerValue();
        pih.addBigIntegerField(fieldName, bi);
      }
        break;
      case DOUBLE:
        pih.addDoubleField(fieldName, jp.getDoubleValue());
        break;
      case FLOAT:
        pih.addFloatField(fieldName, jp.getFloatValue());
        break;
      case INT: {
        int val = jp.getIntValue();
        if (val > Short.MAX_VALUE || val < Short.MIN_VALUE) {
          pih.addIntField(fieldName, val);
        } else if (val > Byte.MAX_VALUE || val < Byte.MIN_VALUE) {
          pih.addShortField(fieldName, (short) val);
        } else {
          pih.addByteField(fieldName, (byte) val);
        }
      }
        break;
      case LONG:
        pih.addLongField(fieldName, jp.getLongValue());
        break;
      default:
        throw new IllegalStateException("setNumberField:unknow number type " + nt);
    }
  }
Converts a PdxInstance into a JSON document in byte-array form

@param pdxInstance The PdxInstance to convert
@return the JSON byte array
@throws JSONFormatterException if unable to create the JSON document
geode-core/src/main/java/org/apache/geode/pdx/JSONFormatter.java