/** * Throws a new IO exception with the given message and a context snippet * with this reader's content. */ final JsonEncodingException syntaxError(String message) throws JsonEncodingException { throw new JsonEncodingException(message + " at path " + getPath()); }
@Override public double nextDouble() throws IOException { Object peeked = require(Object.class, Token.NUMBER); double result; if (peeked instanceof Number) { result = ((Number) peeked).doubleValue(); } else if (peeked instanceof String) { try { result = Double.parseDouble((String) peeked); } catch (NumberFormatException e) { throw typeMismatch(peeked, Token.NUMBER); } } else { throw typeMismatch(peeked, Token.NUMBER); } if (!lenient && (Double.isNaN(result) || Double.isInfinite(result))) { throw new JsonEncodingException("JSON forbids NaN and infinities: " + result + " at path " + getPath()); } remove(); return result; }
throw new JsonEncodingException("JSON forbids NaN and infinities: " + result + " at path " + getPath());
/** * Throws a new IO exception with the given message and a context snippet * with this reader's content. */ final JsonEncodingException syntaxError(String message) throws JsonEncodingException { throw new JsonEncodingException(message + " at path " + getPath()); }
@Override public double nextDouble() throws IOException { Object peeked = require(Object.class, Token.NUMBER); double result; if (peeked instanceof Number) { result = ((Number) peeked).doubleValue(); } else if (peeked instanceof String) { try { result = Double.parseDouble((String) peeked); } catch (NumberFormatException e) { throw typeMismatch(peeked, Token.NUMBER); } } else { throw typeMismatch(peeked, Token.NUMBER); } if (!lenient && (Double.isNaN(result) || Double.isInfinite(result))) { throw new JsonEncodingException("JSON forbids NaN and infinities: " + result + " at path " + getPath()); } remove(); return result; }
throw new JsonEncodingException("JSON forbids NaN and infinities: " + result + " at path " + getPath());