MCPcopy
hub / github.com/google/gson / parseReader

Method parseReader

gson/src/main/java/com/google/gson/JsonParser.java:107–120  ·  view source on GitHub ↗

Parses the complete JSON string provided by the reader into a parse tree. An exception is thrown if the JSON string has multiple top-level JSON elements, or if there is trailing data. <p>The JSON data is parsed in {@linkplain JsonReader#setStrictness(Strictness) lenient mode}. @param reader JSON t

(Reader reader)

Source from the content-addressed store, hash-verified

105 * @since 2.8.6
106 */
107 public static JsonElement parseReader(Reader reader) throws JsonIOException, JsonSyntaxException {
108 try {
109 JsonReader jsonReader = new JsonReader(reader);
110 JsonElement element = parseReader(jsonReader);
111 if (!element.isJsonNull() && jsonReader.peek() != JsonToken.END_DOCUMENT) {
112 throw new JsonSyntaxException("Did not consume the entire document.");
113 }
114 return element;
115 } catch (MalformedJsonException | NumberFormatException e) {
116 throw new JsonSyntaxException(e);
117 } catch (IOException e) {
118 throw new JsonIOException(e);
119 }
120 }
121
122 /**
123 * Returns the next value from the JSON stream as a parse tree. Unlike the other {@code parse}

Callers 9

parseMethod · 0.95
testParseReaderMethod · 0.95
testLegacyStrictMethod · 0.95
testStrictMethod · 0.95
parseStringMethod · 0.95
parseMethod · 0.95

Calls 5

isJsonNullMethod · 0.95
peekMethod · 0.95
parseMethod · 0.95
getStrictnessMethod · 0.45
setStrictnessMethod · 0.45

Tested by 6

testParseReaderMethod · 0.76
testLegacyStrictMethod · 0.76
testStrictMethod · 0.76