public static JsonElement parseReader(Reader reader) throws JsonIOException, JsonSyntaxException {
    try {
      JsonReader jsonReader = new JsonReader(reader);
      JsonElement element = parseReader(jsonReader);
      if (!element.isJsonNull() && jsonReader.peek() != JsonToken.END_DOCUMENT) {
        throw new JsonSyntaxException("Did not consume the entire document.");
      }
      return element;
    } catch (MalformedJsonException e) {
      throw new JsonSyntaxException(e);
    } catch (IOException e) {
      throw new JsonIOException(e);
    } catch (NumberFormatException e) {
      throw new JsonSyntaxException(e);
    }
  }
@Test
  public void testLegacyStrict() {
    JsonReader reader = new JsonReader(new StringReader("unquoted"));
    Strictness strictness = Strictness.LEGACY_STRICT;
    // LEGACY_STRICT is ignored by JsonParser later; parses in lenient mode instead
    reader.setStrictness(strictness);

    assertThat(JsonParser.parseReader(reader)).isEqualTo(new JsonPrimitive("unquoted"));
    // Original strictness was restored
    assertThat(reader.getStrictness()).isEqualTo(strictness);
  }