private JsonElement readTerminal(JsonReader in, JsonToken peeked) throws IOException {
      switch (peeked) {
        case STRING:
          String value = in.nextString();
          if (!isValidString(value)) {
            throw new IOException("illegal characters in string");
          }
          return new JsonPrimitive(value);
        case NUMBER:
          String number = in.nextString();
          return new JsonPrimitive(new LazilyParsedNumber(number));
        case BOOLEAN:
          return new JsonPrimitive(in.nextBoolean());
        case NULL:
          in.nextNull();
          return JsonNull.INSTANCE;
        default:
          // When read(JsonReader) is called with JsonReader in invalid state
          throw new IllegalStateException("Unexpected token: " + peeked);
      }
    }
Reads a {@link JsonElement} which cannot have any nested elements
java_src/src/main/java/com/google/crypto/tink/internal/JsonParser.java