当前位置: 首页>>代码示例>>Java>>正文


Java Streams.write方法代码示例

本文整理汇总了Java中com.google.gson.internal.Streams.write方法的典型用法代码示例。如果您正苦于以下问题:Java Streams.write方法的具体用法?Java Streams.write怎么用?Java Streams.write使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.gson.internal.Streams的用法示例。


在下文中一共展示了Streams.write方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: toJson

import com.google.gson.internal.Streams; //导入方法依赖的package包/类
public void toJson(JsonElement jsonElement, JsonWriter writer) throws JsonIOException {
    boolean oldLenient = writer.isLenient();
    writer.setLenient(true);
    boolean oldHtmlSafe = writer.isHtmlSafe();
    writer.setHtmlSafe(this.htmlSafe);
    boolean oldSerializeNulls = writer.getSerializeNulls();
    writer.setSerializeNulls(this.serializeNulls);
    try {
        Streams.write(jsonElement, writer);
        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,代码行数:21,代码来源:Gson.java

示例2: toJson

import com.google.gson.internal.Streams; //导入方法依赖的package包/类
/**
 * 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);
  }
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:22,代码来源:Gson.java

示例3: write

import com.google.gson.internal.Streams; //导入方法依赖的package包/类
public final void write(JsonWriter paramJsonWriter, T paramT)
  throws IOException
{
  if (this.serializer == null)
  {
    delegate().write(paramJsonWriter, paramT);
    return;
  }
  if (paramT == null)
  {
    paramJsonWriter.nullValue();
    return;
  }
  JsonSerializer localJsonSerializer = this.serializer;
  Streams.write(localJsonSerializer.serialize$117eb95b(paramT), paramJsonWriter);
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:17,代码来源:TreeTypeAdapter.java

示例4: toString

import com.google.gson.internal.Streams; //导入方法依赖的package包/类
public String toString()
{
  try
  {
    StringWriter localStringWriter = new StringWriter();
    JsonWriter localJsonWriter = new JsonWriter(localStringWriter);
    localJsonWriter.lenient = true;
    Streams.write(this, localJsonWriter);
    String str = localStringWriter.toString();
    return str;
  }
  catch (IOException localIOException)
  {
    throw new AssertionError(localIOException);
  }
}
 
开发者ID:ChiangC,项目名称:FMTech,代码行数:17,代码来源:JsonElement.java

示例5: toString

import com.google.gson.internal.Streams; //导入方法依赖的package包/类
public String toString()
{
    String s;
    try
    {
        StringWriter stringwriter = new StringWriter();
        JsonWriter jsonwriter = new JsonWriter(stringwriter);
        jsonwriter.setLenient(true);
        Streams.write(this, jsonwriter);
        s = stringwriter.toString();
    }
    catch (IOException ioexception)
    {
        throw new AssertionError(ioexception);
    }
    return s;
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:18,代码来源:JsonElement.java

示例6: write

import com.google.gson.internal.Streams; //导入方法依赖的package包/类
public void write(JsonWriter jsonwriter, Object obj)
{
    if (a == null)
    {
        a().write(jsonwriter, obj);
        return;
    }
    if (obj == null)
    {
        jsonwriter.nullValue();
        return;
    } else
    {
        Streams.write(a.serialize(obj, d.getType(), c.c), jsonwriter);
        return;
    }
}
 
开发者ID:vishnudevk,项目名称:MiBandDecompiled,代码行数:18,代码来源:o.java

示例7: write

import com.google.gson.internal.Streams; //导入方法依赖的package包/类
public void write(JsonWriter out, T value) throws IOException {
    if (this.serializer == null) {
        delegate().write(out, value);
    } else if (value == null) {
        out.nullValue();
    } else {
        Streams.write(this.serializer.serialize(value, this.typeToken.getType(), this.gson.serializationContext), out);
    }
}
 
开发者ID:JackChan1999,项目名称:letv,代码行数:10,代码来源:TreeTypeAdapter.java

示例8: toString

import com.google.gson.internal.Streams; //导入方法依赖的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

示例9: write

import com.google.gson.internal.Streams; //导入方法依赖的package包/类
@Override public void write(JsonWriter out, T value) throws IOException {
  if (serializer == null) {
    delegate().write(out, value);
    return;
  }
  if (value == null) {
    out.nullValue();
    return;
  }
  JsonElement tree = serializer.serialize(value, typeToken.getType(), gson.serializationContext);
  Streams.write(tree, out);
}
 
开发者ID:odoo-mobile-intern,项目名称:odoo-work,代码行数:13,代码来源:TreeTypeAdapter.java

示例10: toString

import com.google.gson.internal.Streams; //导入方法依赖的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

示例11: write

import com.google.gson.internal.Streams; //导入方法依赖的package包/类
public void write(JsonWriter out, T value) throws IOException {
    if (this.serializer == null) {
        delegate().write(out, value);
    } else if (value == null) {
        out.nullValue();
    } else {
        Streams.write(this.serializer.serialize(value, this.typeToken.getType(), this.gson
                .serializationContext), out);
    }
}
 
开发者ID:JackChan1999,项目名称:boohee_v5.6,代码行数:11,代码来源:TreeTypeAdapter.java

示例12: write

import com.google.gson.internal.Streams; //导入方法依赖的package包/类
@Override public void write(JsonWriter out, T value) throws IOException {
  if (serializer == null) {
    delegate().write(out, value);
    return;
  }
  if (value == null) {
    out.nullValue();
    return;
  }
  JsonElement tree = serializer.serialize(value, typeToken.getType(), context);
  Streams.write(tree, out);
}
 
开发者ID:MyJojoX,项目名称:MyJojoXUtils,代码行数:13,代码来源:TreeTypeAdapter.java

示例13: toString

import com.google.gson.internal.Streams; //导入方法依赖的package包/类
public static String toString(JsonObject obj) {
    try {
        StringWriter stringWriter = new StringWriter();
        JsonWriter jsonWriter = new JsonWriter(stringWriter);
        jsonWriter.setIndent("  ");
        jsonWriter.setLenient(true);
        Streams.write(obj, jsonWriter);
        return stringWriter.toString();
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}
 
开发者ID:mlhartme,项目名称:stool,代码行数:13,代码来源:Transform.java

示例14: write

import com.google.gson.internal.Streams; //导入方法依赖的package包/类
@Override
public void write(JsonWriter out, Extensions value) throws IOException {
    Switch s;

    out.beginObject();
    for (Map.Entry<String, Switch> entry : value.extensions.entrySet()) {
        s = entry.getValue();
        out.name(s.marker() + entry.getKey());
        Streams.write(gson.toJsonTree(s.extension), out);
    }
    out.endObject();
}
 
开发者ID:mlhartme,项目名称:stool,代码行数:13,代码来源:ExtensionsAdapter.java

示例15: setNonNullParameter

import com.google.gson.internal.Streams; //导入方法依赖的package包/类
@Override
public void setNonNullParameter(PreparedStatement ps, int i, JsonElement parameter, JdbcType jdbcType) throws SQLException {
    try {
        StringWriter sw = new StringWriter();
        JsonWriter jsonWriter = new JsonWriter(sw);
        jsonWriter.setLenient(false);
        Streams.write(parameter, jsonWriter);
        ps.setString(i, sw.toString());
    } catch (IOException ex) {
        throw new RuntimeException(ex.getMessage(), ex);
    }
}
 
开发者ID:javaplugs,项目名称:mybatis-gson,代码行数:13,代码来源:JsonElementTypeHandler.java


注:本文中的com.google.gson.internal.Streams.write方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。