public static String numberToString(Number number) throws JSONException {
  if (number == null) {
    throw new JSONException("Number must be non-null");
  }
  double doubleValue=number.doubleValue();
  JSON.checkDouble(doubleValue);
  if (number.equals(NEGATIVE_ZERO)) {
    return "-0";
  }
  long longValue=number.longValue();
  if (doubleValue == (double)longValue) {
    return Long.toString(longValue);
  }
  return number.toString();
}

public static String numberToString ( Number number ) throws JSONException { if ( number == null ) { throw new JSONException ( "Number must be non-null" ) ; } double doubleValue = number . doubleValue ( ) ; JSON . checkDouble ( doubleValue ) ; if ( number . equals ( NEGATIVE_ZERO ) ) { return "-0" ; } long longValue = number . longValue ( ) ; if ( doubleValue == ( double ) longValue ) { return Long . toString ( longValue ) ; } return number . toString ( ) ; }
encodes the number as a json string .
