Exemplo n.º 1
0
 /**
  * Writes the JSON for {@code jsonElement} to {@code writer}.
  *
  * @throws JsonIOException if there was a problem writing to the writer
  */
 public void toJson(JsonElement jsonElement, JsonWriter writer) throws JsonIOException {
   boolean oldLenient = writer.isLenient();
   writer.setLenient(true);
   boolean oldHtmlSafe = writer.isHtmlSafe();
   writer.setHtmlSafe(htmlSafe);
   boolean oldSerializeNulls = writer.getSerializeNulls();
   writer.setSerializeNulls(serializeNulls);
   try {
     Streams.write(jsonElement, writer);
   } catch (IOException e) {
     throw new JsonIOException(e);
   } finally {
     writer.setLenient(oldLenient);
     writer.setHtmlSafe(oldHtmlSafe);
     writer.setSerializeNulls(oldSerializeNulls);
   }
 }
Exemplo n.º 2
0
 /**
  * Writes the JSON representation of {@code src} of type {@code typeOfSrc} to {@code writer}.
  *
  * @throws JsonIOException if there was a problem writing to the writer
  */
 @SuppressWarnings("unchecked")
 public void toJson(Object src, Type typeOfSrc, JsonWriter writer) throws JsonIOException {
   TypeAdapter<?> adapter = getAdapter(TypeToken.get(typeOfSrc));
   boolean oldLenient = writer.isLenient();
   writer.setLenient(true);
   boolean oldHtmlSafe = writer.isHtmlSafe();
   writer.setHtmlSafe(htmlSafe);
   boolean oldSerializeNulls = writer.getSerializeNulls();
   writer.setSerializeNulls(serializeNulls);
   try {
     ((TypeAdapter<Object>) adapter).write(writer, src);
   } catch (IOException e) {
     throw new JsonIOException(e);
   } finally {
     writer.setLenient(oldLenient);
     writer.setHtmlSafe(oldHtmlSafe);
     writer.setSerializeNulls(oldSerializeNulls);
   }
 }
Exemplo n.º 3
0
 public void toJson(JsonElement jsonElement, JsonWriter jsonWriter) throws JsonIOException {
   boolean isLenient = jsonWriter.isLenient();
   jsonWriter.setLenient(true);
   boolean isHtmlSafe = jsonWriter.isHtmlSafe();
   jsonWriter.setHtmlSafe(this.htmlSafe);
   boolean serializeNulls = jsonWriter.getSerializeNulls();
   jsonWriter.setSerializeNulls(this.serializeNulls);
   try {
     Streams.write(jsonElement, jsonWriter);
     jsonWriter.setLenient(isLenient);
     jsonWriter.setHtmlSafe(isHtmlSafe);
     jsonWriter.setSerializeNulls(serializeNulls);
   } catch (Throwable e) {
     throw new JsonIOException(e);
   } catch (Throwable th) {
     jsonWriter.setLenient(isLenient);
     jsonWriter.setHtmlSafe(isHtmlSafe);
     jsonWriter.setSerializeNulls(serializeNulls);
   }
 }
Exemplo n.º 4
0
 public void toJson(JsonElement paramJsonElement, JsonWriter paramJsonWriter)
     throws JsonIOException {
   boolean bool1 = paramJsonWriter.isLenient();
   paramJsonWriter.setLenient(true);
   boolean bool2 = paramJsonWriter.isHtmlSafe();
   paramJsonWriter.setHtmlSafe(this.htmlSafe);
   boolean bool3 = paramJsonWriter.getSerializeNulls();
   paramJsonWriter.setSerializeNulls(this.serializeNulls);
   try {
     Streams.write(paramJsonElement, paramJsonWriter);
     return;
   } catch (IOException paramJsonElement) {
     throw new JsonIOException(paramJsonElement);
   } finally {
     paramJsonWriter.setLenient(bool1);
     paramJsonWriter.setHtmlSafe(bool2);
     paramJsonWriter.setSerializeNulls(bool3);
   }
   throw paramJsonElement;
 }
Exemplo n.º 5
0
 public void toJson(Object obj, Type type, JsonWriter jsonWriter) throws JsonIOException {
   TypeAdapter adapter = getAdapter(TypeToken.get(type));
   boolean isLenient = jsonWriter.isLenient();
   jsonWriter.setLenient(true);
   boolean isHtmlSafe = jsonWriter.isHtmlSafe();
   jsonWriter.setHtmlSafe(this.htmlSafe);
   boolean serializeNulls = jsonWriter.getSerializeNulls();
   jsonWriter.setSerializeNulls(this.serializeNulls);
   try {
     adapter.write(jsonWriter, obj);
     jsonWriter.setLenient(isLenient);
     jsonWriter.setHtmlSafe(isHtmlSafe);
     jsonWriter.setSerializeNulls(serializeNulls);
   } catch (Throwable e) {
     throw new JsonIOException(e);
   } catch (Throwable th) {
     jsonWriter.setLenient(isLenient);
     jsonWriter.setHtmlSafe(isHtmlSafe);
     jsonWriter.setSerializeNulls(serializeNulls);
   }
 }
Exemplo n.º 6
0
 public void toJson(Object paramObject, Type paramType, JsonWriter paramJsonWriter)
     throws JsonIOException {
   paramType = getAdapter(TypeToken.get(paramType));
   boolean bool1 = paramJsonWriter.isLenient();
   paramJsonWriter.setLenient(true);
   boolean bool2 = paramJsonWriter.isHtmlSafe();
   paramJsonWriter.setHtmlSafe(this.htmlSafe);
   boolean bool3 = paramJsonWriter.getSerializeNulls();
   paramJsonWriter.setSerializeNulls(this.serializeNulls);
   try {
     paramType.write(paramJsonWriter, paramObject);
     return;
   } catch (IOException paramObject) {
     throw new JsonIOException(paramObject);
   } finally {
     paramJsonWriter.setLenient(bool1);
     paramJsonWriter.setHtmlSafe(bool2);
     paramJsonWriter.setSerializeNulls(bool3);
   }
   throw paramObject;
 }