當前位置: 首頁>>代碼示例>>Java>>正文


Java JsonWriter.setLenient方法代碼示例

本文整理匯總了Java中com.google.gson.stream.JsonWriter.setLenient方法的典型用法代碼示例。如果您正苦於以下問題:Java JsonWriter.setLenient方法的具體用法?Java JsonWriter.setLenient怎麽用?Java JsonWriter.setLenient使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在com.google.gson.stream.JsonWriter的用法示例。


在下文中一共展示了JsonWriter.setLenient方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: toJson

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
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(this.htmlSafe);
    boolean oldSerializeNulls = writer.getSerializeNulls();
    writer.setSerializeNulls(this.serializeNulls);
    try {
        adapter.write(writer, src);
        writer.setLenient(oldLenient);
        writer.setHtmlSafe(oldHtmlSafe);
        writer.setSerializeNulls(oldSerializeNulls);
    } catch (Throwable e) {
        throw new JsonIOException(e);
    } catch (Throwable th) {
        writer.setLenient(oldLenient);
        writer.setHtmlSafe(oldHtmlSafe);
        writer.setSerializeNulls(oldSerializeNulls);
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:22,代碼來源:Gson.java

示例2: toJson

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
/**
 * 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);
  }
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:25,代碼來源:Gson.java

示例3: toString

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
public String toString() {
    try {
        StringWriter stringWriter = new StringWriter();
        JsonWriter jsonWriter = new JsonWriter(stringWriter);
        jsonWriter.setLenient(true);
        Streams.write(this, jsonWriter);
        return stringWriter.toString();
    } catch (IOException e) {
        throw new AssertionError(e);
    }
}
 
開發者ID:JackChan1999,項目名稱:letv,代碼行數:12,代碼來源:JsonElement.java

示例4: toString

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
/**
 * Returns a String representation of this element.
 */
@Override
public String toString() {
  try {
    StringWriter stringWriter = new StringWriter();
    JsonWriter jsonWriter = new JsonWriter(stringWriter);
    jsonWriter.setLenient(true);
    Streams.write(this, jsonWriter);
    return stringWriter.toString();
  } catch (IOException e) {
    throw new AssertionError(e);
  }
}
 
開發者ID:odoo-mobile-intern,項目名稱:odoo-work,代碼行數:16,代碼來源:JsonElement.java

示例5: setWriterOptions

import com.google.gson.stream.JsonWriter; //導入方法依賴的package包/類
void setWriterOptions(JsonWriter writer) {
  writer.setSerializeNulls(serializeNulls);
  writer.setLenient(lenient);
  writer.setHtmlSafe(htmlSafe);
  writer.setIndent(prettyPrinting ? "  " : "");
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:7,代碼來源:GsonMessageBodyProvider.java


注:本文中的com.google.gson.stream.JsonWriter.setLenient方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。