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

Method parse

src/main/java/com/google/gson/Streams.java:35–57  ·  view source on GitHub ↗

Takes a reader in any state and returns the next value as a JsonElement.

(JsonReader reader)

Source from the content-addressed store, hash-verified

33 * Takes a reader in any state and returns the next value as a JsonElement.
34 */
35 static JsonElement parse(JsonReader reader) throws JsonParseException {
36 boolean isEmpty = true;
37 try {
38 reader.peek();
39 isEmpty = false;
40 return parseRecursive(reader);
41 } catch (EOFException e) {
42 /*
43 * For compatibility with JSON 1.5 and earlier, we return a JsonNull for
44 * empty documents instead of throwing.
45 */
46 if (isEmpty) {
47 return JsonNull.createJsonNull();
48 }
49 throw new JsonIOException(e);
50 } catch (MalformedJsonException e) {
51 throw new JsonSyntaxException(e);
52 } catch (IOException e) {
53 throw new JsonIOException(e);
54 } catch (NumberFormatException e) {
55 throw new JsonSyntaxException(e);
56 }
57 }
58
59 private static JsonElement parseRecursive(JsonReader reader) throws IOException {
60 switch (reader.peek()) {

Callers 4

nextMethod · 0.95
parseMethod · 0.95
fromJsonMethod · 0.95

Calls 3

parseRecursiveMethod · 0.95
createJsonNullMethod · 0.95
peekMethod · 0.45

Tested by 1