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

Method read

gson/src/test/java/com/google/gson/SubsetTest.java:10–18  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8/** Tests that we can parse and create JSON using the {@link JsonElement} subset. */
9public final class SubsetTest {
10 @Test
11 public void read() {
12 JsonElement json = JsonParser.parseString("{\"a\":1,\"b\":[2.1, null]}");
13 assertThat(json.isJsonObject()).isTrue();
14 JsonObject jsonObject = json.getAsJsonObject();
15 assertThat(jsonObject.get("a").getAsInt()).isEqualTo(1);
16 assertThat(jsonObject.get("b").getAsJsonArray().asList())
17 .isEqualTo(List.of(new JsonPrimitive(2.1), JsonNull.INSTANCE));
18 }
19
20 @Test
21 public void write() {

Callers

nothing calls this directly

Calls 8

parseStringMethod · 0.95
isJsonObjectMethod · 0.95
getAsJsonObjectMethod · 0.95
getMethod · 0.95
asListMethod · 0.80
getAsIntMethod · 0.45
getAsJsonArrayMethod · 0.45
ofMethod · 0.45

Tested by

no test coverage detected