src/main/java/com/github/wnameless/json/base/JsonValueUtils.java
public static Number toJavaNumber(BigDecimal bd) {
    if (BigDecimal.valueOf(bd.intValue()).equals(bd)) {
      return bd.intValue();
    }
    if (BigDecimal.valueOf(bd.longValue()).equals(bd)) {
      return bd.longValue();
    }
    if (bd.scale() <= 0) {
      return bd.toBigInteger();
    }
    if (BigDecimal.valueOf(bd.doubleValue()).compareTo(bd) == 0) {
      return bd.doubleValue();
    }
    return bd;
  }
/**
   * Creates a {@link Number} by given {@link BigDecimal} from {@link Integer},
   * {@link Long}, {@link BigInteger}, {@link Double} and {@link BigDecimal}
   * based on the size and scale of numeric.
   * 
   * @param bd
   *          a {@link BigDecimal}
   * @return a {@link Number}
   */
Creates a  Number by given  BigDecimal from  Integer,
Long,  BigInteger,  Double and  BigDecimal
based on the size and scale of numeric.

@param bd
a  BigDecimal
@return a  Number
Creates a Number by given BigDecimal from Integer Long BigInteger Double and BigDecimal based on the size and scale of numeric . @param bd a BigDecimal @return a Number
public static Number toJavaNumber(BigDecimal bd) {
    if (BigDecimal.valueOf(bd.intValue()).equals(bd)) {
      return bd.intValue();
    }
    if (BigDecimal.valueOf(bd.longValue()).equals(bd)) {
      return bd.longValue();
    }
    if (bd.scale() <= 0) {
      return bd.toBigInteger();
    }
    if (BigDecimal.valueOf(bd.doubleValue()).compareTo(bd) == 0) {
      return bd.doubleValue();
    }
    return bd;
  }
public static Number toJavaNumber ( BigDecimal bd ) { if ( BigDecimal . valueOf ( bd . intValue ( ) ) . equals ( bd ) ) { return bd . intValue ( ) ; } if ( BigDecimal . valueOf ( bd . longValue ( ) ) . equals ( bd ) ) { return bd . longValue ( ) ; } if ( bd . scale ( ) <= 0 ) { return bd . toBigInteger ( ) ; } if ( BigDecimal . valueOf ( bd . doubleValue ( ) ) . compareTo ( bd ) == 0 ) { return bd . doubleValue ( ) ; } return bd ; }
Creates a {@link Number} by given {@link BigDecimal} from {@link Integer},
 {@link Long}, {@link BigInteger}, {@link Double} and {@link BigDecimal}
 based on the size and scale of numeric.
Creates a { @link Number } by given { @link BigDecimal } from { @link Integer } { @link Long } { @link BigInteger } { @link Double } and { @link BigDecimal } based on the size and scale of numeric .