コード例 #1
0
ファイル: Streams.java プロジェクト: matrixxun/FMTech
 public static JsonElement parse(JsonReader paramJsonReader) throws JsonParseException {
   int i = 1;
   try {
     paramJsonReader.peek();
     i = 0;
     JsonElement localJsonElement = (JsonElement) TypeAdapters.JSON_ELEMENT.read(paramJsonReader);
     return localJsonElement;
   } catch (EOFException localEOFException) {
     if (i != 0) {
       return JsonNull.INSTANCE;
     }
     throw new JsonIOException(localEOFException);
   } catch (MalformedJsonException localMalformedJsonException) {
     throw new JsonSyntaxException(localMalformedJsonException);
   } catch (IOException localIOException) {
     throw new JsonIOException(localIOException);
   } catch (NumberFormatException localNumberFormatException) {
     throw new JsonSyntaxException(localNumberFormatException);
   }
 }
コード例 #2
0
ファイル: Streams.java プロジェクト: kettas/gson
 /** 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 {
     reader.peek();
     isEmpty = false;
     return TypeAdapters.JSON_ELEMENT.read(reader);
   } 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);
   } catch (IOException e) {
     throw new JsonIOException(e);
   } catch (NumberFormatException e) {
     throw new JsonSyntaxException(e);
   }
 }
コード例 #3
0
ファイル: Streams.java プロジェクト: kettas/gson
 /** Writes the JSON element to the writer, recursively. */
 public static void write(JsonElement element, JsonWriter writer) throws IOException {
   TypeAdapters.JSON_ELEMENT.write(writer, element);
 }