本文整理汇总了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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
示例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();
}
示例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);
}
}