Code example for JsonReader

Methods: peek

   * Takes a reader in any state and returns the next value as a JsonElement. 
  public static JsonElement parse(JsonReader reader) throws JsonParseException {
    boolean isEmpty = true;
    try { 
      isEmpty = false;
    } catch (EOFException e) {
       * For compatibility with JSON 1.5 and earlier, we return a JsonNull for 
       * empty documents instead of throwing. 
      if (isEmpty) {
        return JsonNull.INSTANCE;
      // The stream ended prematurely so it is likely a syntax error. 
      throw new JsonSyntaxException(e);
    } catch (MalformedJsonException e) {
      throw new JsonSyntaxException(e);