当前位置: 首页>>代码示例>>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;未经允许,请勿转载。