@Test public void testReadDoubleAsFloat() { assertEquals(-1.1f, createReader("-1.1").valueAsFloat(), 0); }
public float valueAsFloat() { if (DOUBLE == valueType) { return (float) _doubleValue; } else if (INTEGER == valueType) { return Long.valueOf(_intValue).floatValue(); } else if (STRING == valueType) return Float.parseFloat(_stringValue); throw new JsonStreamException("Expected a float but value is of type " + valueType); }
JsonReader implements ObjectReader { public float valueAsFloat() { if (DOUBLE == valueType) { return (float) _doubleValue; } else if (INTEGER == valueType) { return Long.valueOf(_intValue).floatValue(); } else if (STRING == valueType) return Float.parseFloat(_stringValue); throw new JsonStreamException("Expected a float but value is of type " + valueType); } }
JsonReader implements ObjectReader { public float valueAsFloat() { if (DOUBLE == valueType) { return (float) _doubleValue; } else if (INTEGER == valueType) { return Long.valueOf(_intValue).floatValue(); } else if (STRING == valueType) return Float.parseFloat(_stringValue); throw new JsonStreamException("Expected a float but value is of type " + valueType); } JsonReader(String source);  JsonReader(Reader reader, boolean strictDoubleParse, boolean readMetadata); }
JsonReader implements ObjectReader { public float valueAsFloat() { if (DOUBLE == valueType) { return (float) _doubleValue; } else if (INTEGER == valueType) { return Long.valueOf(_intValue).floatValue(); } else if (STRING == valueType) return Float.parseFloat(_stringValue); throw new JsonStreamException("Expected a float but value is of type " + valueType); } JsonReader(String source);  JsonReader(Reader reader, boolean strictDoubleParse, boolean readMetadata); void close(); ObjectReader beginArray(); ObjectReader beginObject(); ObjectReader nextObjectMetadata(); ObjectReader endArray(); ObjectReader endObject(); String name(); String valueAsString(); int valueAsInt(); long valueAsLong(); double valueAsDouble(); short valueAsShort(); float valueAsFloat(); boolean valueAsBoolean(); byte[] valueAsByteArray(); String metadata(String name); ValueType getValueType(); ObjectReader skipValue(); boolean hasNext(); ValueType next(); @Override JsonType enclosingType(); int column(); int row(); }
JsonReader implements ObjectReader { public float valueAsFloat() { if (DOUBLE == valueType) { return (float) _doubleValue; } else if (INTEGER == valueType) { return Long.valueOf(_intValue).floatValue(); } else if (STRING == valueType) return Float.parseFloat(_stringValue); throw new JsonStreamException("Expected a float but value is of type " + valueType); } JsonReader(String source);  JsonReader(Reader reader, boolean strictDoubleParse, boolean readMetadata); void close(); ObjectReader beginArray(); ObjectReader beginObject(); ObjectReader nextObjectMetadata(); ObjectReader endArray(); ObjectReader endObject(); String name(); String valueAsString(); int valueAsInt(); long valueAsLong(); double valueAsDouble(); short valueAsShort(); float valueAsFloat(); boolean valueAsBoolean(); byte[] valueAsByteArray(); String metadata(String name); ValueType getValueType(); ObjectReader skipValue(); boolean hasNext(); ValueType next(); @Override JsonType enclosingType(); int column(); int row();  }