@Override public void endNumber(String string) { value = new JsonNumber(string); }
/** * Returns a JsonValue instance that represents the given <code>int</code> value. * * @param value * the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue value(int value) { return new JsonNumber(Integer.toString(value, 10)); }
/** * Returns a JsonValue instance that represents the given <code>long</code> value. * * @param value * the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue value(long value) { return new JsonNumber(Long.toString(value, 10)); }
/** * Returns a JsonValue instance that represents the given <code>float</code> value. * * @param value * the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue value(float value) { if (Float.isInfinite(value) || Float.isNaN(value)) { throw new IllegalArgumentException("Infinite and NaN values not permitted in JSON"); } return new JsonNumber(cutOffPointZero(Float.toString(value))); }
/** * Returns a JsonValue instance that represents the given <code>double</code> value. * * @param value * the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue value(double value) { if (Double.isInfinite(value) || Double.isNaN(value)) { throw new IllegalArgumentException("Infinite and NaN values not permitted in JSON"); } return new JsonNumber(cutOffPointZero(Double.toString(value))); }
@Override public void endNumber(String string) { value = new JsonNumber(string); }
@Override public void endNumber(String string) { value = new JsonNumber(string); }
/** * Returns a JsonValue instance that represents the given <code>long</code> value. * * @param value * the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue value(long value) { return new JsonNumber(Long.toString(value, 10)); }
/** * Returns a JsonValue instance that represents the given <code>int</code> value. * * @param value * the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue value(int value) { return new JsonNumber(Integer.toString(value, 10)); }
/** * Returns a JsonValue instance that represents the given <code>int</code> value. * * @param value * the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue value(int value) { return new JsonNumber(Integer.toString(value, 10)); }
/** * Returns a JsonValue instance that represents the given <code>long</code> value. * * @param value * the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue valueOf( long value ) { return new JsonNumber( Long.toString( value, 10 ) ); }
/** * Returns a JsonValue instance that represents the given <code>long</code> value. * * @param value * the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue value(long value) { return new JsonNumber(Long.toString(value, 10)); }
/** * Returns a JsonValue instance that represents the given <code>int</code> value. * * @param value * the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue valueOf( int value ) { return new JsonNumber( Integer.toString( value, 10 ) ); }
/** * Returns a JsonValue instance that represents the given <code>double</code> value. * * @param value * the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue value(double value) { if (Double.isInfinite(value) || Double.isNaN(value)) { throw new IllegalArgumentException("Infinite and NaN values not permitted in JSON"); } return new JsonNumber(cutOffPointZero(Double.toString(value))); }
/** * Returns a JsonValue instance that represents the given <code>float</code> value. * * @param value * the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue value(float value) { if (Float.isInfinite(value) || Float.isNaN(value)) { throw new IllegalArgumentException("Infinite and NaN values not permitted in JSON"); } return new JsonNumber(cutOffPointZero(Float.toString(value))); }
/** * Returns a JsonValue instance that represents the given <code>double</code> value. * * @param value * the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue valueOf( double value ) { if( Double.isInfinite( value ) || Double.isNaN( value ) ) { throw new IllegalArgumentException( "Infinite and NaN values not permitted in JSON" ); } return new JsonNumber( cutOffPointZero( Double.toString( value ) ) ); }
/** * Returns a JsonValue instance that represents the given <code>double</code> value. * * @param value * the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue value(double value) { if (Double.isInfinite(value) || Double.isNaN(value)) { throw new IllegalArgumentException("Infinite and NaN values not permitted in JSON"); } return new JsonNumber(cutOffPointZero(Double.toString(value))); }
/** * Returns a JsonValue instance that represents the given <code>float</code> value. * * @param value * the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue value(float value) { if (Float.isInfinite(value) || Float.isNaN(value)) { throw new IllegalArgumentException("Infinite and NaN values not permitted in JSON"); } return new JsonNumber(cutOffPointZero(Float.toString(value))); }
/** * Returns a JsonValue instance that represents the given <code>float</code> value. * * @param value * the value to get a JSON representation for * @return a JSON value that represents the given value */ public static JsonValue valueOf( float value ) { if( Float.isInfinite( value ) || Float.isNaN( value ) ) { throw new IllegalArgumentException( "Infinite and NaN values not permitted in JSON" ); } return new JsonNumber( cutOffPointZero( Float.toString( value ) ) ); }
private JsonValue readNumber() throws IOException { startCapture(); readChar( '-' ); int firstDigit = current; if( !readDigit() ) { throw expected( "digit" ); } if( firstDigit != '0' ) { while( readDigit() ) { } } readFraction(); readExponent(); return new JsonNumber( endCapture() ); }