Java Code Examples for com.google.gson.stream.JsonReader#getPath()
The following examples show how to use
com.google.gson.stream.JsonReader#getPath() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JsonParser.java From grpc-nebula-java with Apache License 2.0 | 6 votes |
private static Object parseRecursive(JsonReader jr) throws IOException { checkState(jr.hasNext(), "unexpected end of JSON"); switch (jr.peek()) { case BEGIN_ARRAY: return parseJsonArray(jr); case BEGIN_OBJECT: return parseJsonObject(jr); case STRING: return jr.nextString(); case NUMBER: return jr.nextDouble(); case BOOLEAN: return jr.nextBoolean(); case NULL: return parseJsonNull(jr); default: throw new IllegalStateException("Bad token: " + jr.getPath()); } }
Example 2
Source File: DBFluteGsonAdaptable.java From lastaflute with Apache License 2.0 | 6 votes |
protected void throwJsonPropertyUnknownClassificationCodeException(String code, JsonReader in, ClassificationUnknownCodeException e) { final String propertyPath = in.getPath(); final ExceptionMessageBuilder br = new ExceptionMessageBuilder(); br.addNotice("Unknown classification code for the JSON property."); br.addItem("Advice"); br.addElement("Make sure your classification code in requested JSON."); br.addElement("And confirm the classification elements."); br.addItem("Classification"); br.addElement(clsType); br.addItem("Unknown Code"); br.addElement(code); br.addItem("JSON Property"); br.addElement(propertyPath); final String msg = br.buildExceptionMessage(); throw new JsonPropertyClassificationCodeUnknownException(msg, clsType, propertyPath, e); }
Example 3
Source File: Java8TimeGsonAdaptable.java From lastaflute with Apache License 2.0 | 6 votes |
protected void throwJsonPropertyDateTimeParseFailureException(DateTimeFormatter formatter, String exp, JsonReader in, DateTimeParseException e) { final Class<?> dateType = getDateType(); final String properthPath = in.getPath(); final ExceptionMessageBuilder br = new ExceptionMessageBuilder(); br.addNotice("Failed to parse date-time for the JSON property."); br.addItem("Advice"); br.addElement("Confirm your date-time format for the JSON property."); br.addItem("Formatter"); br.addElement(formatter); br.addItem("DateTime Type"); br.addElement(dateType); br.addItem("Specified Expression"); br.addElement(exp); br.addItem("JSON Property"); br.addElement(properthPath); final String msg = br.buildExceptionMessage(); throw new JsonPropertyDateTimeParseFailureException(msg, dateType, properthPath, e); }
Example 4
Source File: JsonParser.java From grpc-java with Apache License 2.0 | 6 votes |
private static Object parseRecursive(JsonReader jr) throws IOException { checkState(jr.hasNext(), "unexpected end of JSON"); switch (jr.peek()) { case BEGIN_ARRAY: return parseJsonArray(jr); case BEGIN_OBJECT: return parseJsonObject(jr); case STRING: return jr.nextString(); case NUMBER: return jr.nextDouble(); case BOOLEAN: return jr.nextBoolean(); case NULL: return parseJsonNull(jr); default: throw new IllegalStateException("Bad token: " + jr.getPath()); } }
Example 5
Source File: TextColorWrapper.java From adventure with MIT License | 5 votes |
@Override public TextColorWrapper read(final JsonReader in) throws IOException { final String input = in.nextString(); final TextColor color = TextColorSerializer.fromString(input); final TextDecoration decoration = TextDecoration.NAMES.value(input); final boolean reset = decoration == null && input.equals("reset"); if(color == null && decoration == null && !reset) { throw new JsonParseException("Don't know how to parse " + input + " at " + in.getPath()); } return new TextColorWrapper(color, decoration, reset); }
Example 6
Source File: NumberGsonAdaptable.java From lastaflute with Apache License 2.0 | 5 votes |
protected void throwJsonPropertyNumberParseFailureException(JsonReader in, RuntimeException e) { final Class<?> numberType = getNumberType(); final String properthPath = in.getPath(); final ExceptionMessageBuilder br = new ExceptionMessageBuilder(); br.addNotice("Failed to parse number for the JSON property."); br.addItem("Advice"); br.addElement("Confirm the next exception message."); br.addElement("And make sure your specified value for the JSON property."); br.addItem("Number Type"); br.addElement(numberType.getName()); br.addItem("JSON Property"); br.addElement(properthPath); final String msg = br.buildExceptionMessage(); throw new JsonPropertyNumberParseFailureException(msg, numberType, properthPath, e); }