本文整理汇总了Java中com.google.gson.internal.bind.JsonTreeWriter类的典型用法代码示例。如果您正苦于以下问题:Java JsonTreeWriter类的具体用法?Java JsonTreeWriter怎么用?Java JsonTreeWriter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
JsonTreeWriter类属于com.google.gson.internal.bind包,在下文中一共展示了JsonTreeWriter类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toJsonTree
import com.google.gson.internal.bind.JsonTreeWriter; //导入依赖的package包/类
final JsonElement toJsonTree(T value) {
try {
JsonTreeWriter jsonWriter = new JsonTreeWriter();
jsonWriter.setLenient(true);
write(jsonWriter, value);
return jsonWriter.get();
} catch (Throwable e) {
throw new JsonIOException(e);
}
}
示例2: toJsonTree
import com.google.gson.internal.bind.JsonTreeWriter; //导入依赖的package包/类
/**
* Converts {@code value} to a JSON tree.
*
* @param value the Java object to convert. May be null.
* @return the converted JSON tree. May be {@link JsonNull}.
* @since 2.2
*/
public final JsonElement toJsonTree(T value) {
try {
JsonTreeWriter jsonWriter = new JsonTreeWriter();
write(jsonWriter, value);
return jsonWriter.get();
} catch (IOException e) {
throw new JsonIOException(e);
}
}
示例3: toJsonTree
import com.google.gson.internal.bind.JsonTreeWriter; //导入依赖的package包/类
public final JsonElement toJsonTree(T value) {
try {
JsonTreeWriter jsonWriter = new JsonTreeWriter();
write(jsonWriter, value);
return jsonWriter.get();
} catch (Throwable e) {
throw new JsonIOException(e);
}
}
示例4: toJsonTree
import com.google.gson.internal.bind.JsonTreeWriter; //导入依赖的package包/类
public final JsonElement toJsonTree(Object obj)
{
JsonElement jsonelement;
try
{
JsonTreeWriter jsontreewriter = new JsonTreeWriter();
write(jsontreewriter, obj);
jsonelement = jsontreewriter.get();
}
catch (IOException ioexception)
{
throw new JsonIOException(ioexception);
}
return jsonelement;
}
示例5: toJsonTree
import com.google.gson.internal.bind.JsonTreeWriter; //导入依赖的package包/类
/**
* Converts {@code value} to a JSON tree.
*
* @param value the Java object to convert. May be null.
* @return the converted JSON tree. May be {@link com.google.gson.JsonNull}.
* @since 2.2
*/
public final JsonElement toJsonTree(T value) {
try {
JsonTreeWriter jsonWriter = new JsonTreeWriter();
write(jsonWriter, value);
return jsonWriter.get();
} catch (IOException e) {
throw new JsonIOException(e);
}
}
示例6: JsonTreeWriter
import com.google.gson.internal.bind.JsonTreeWriter; //导入依赖的package包/类
/**
* Converts {@code value} to a JSON tree.
*
* @param value the Java object to convert. May be null.
* @return the converted JSON tree. May be {@link JsonNull}.
*/
/*public*/ final JsonElement toJsonTree(T value) {
try {
JsonTreeWriter jsonWriter = new JsonTreeWriter();
jsonWriter.setLenient(true);
write(jsonWriter, value);
return jsonWriter.get();
} catch (IOException e) {
throw new JsonIOException(e);
}
}
示例7: toJsonTree
import com.google.gson.internal.bind.JsonTreeWriter; //导入依赖的package包/类
public JsonElement toJsonTree(Object src, Type typeOfSrc) {
JsonWriter writer = new JsonTreeWriter();
toJson(src, typeOfSrc, writer);
return writer.get();
}
示例8: toJsonTree
import com.google.gson.internal.bind.JsonTreeWriter; //导入依赖的package包/类
public JsonElement toJsonTree(Object obj, Type type)
{
JsonTreeWriter jsontreewriter = new JsonTreeWriter();
toJson(obj, type, jsontreewriter);
return jsontreewriter.get();
}
示例9: toJsonTree
import com.google.gson.internal.bind.JsonTreeWriter; //导入依赖的package包/类
/**
* This method serializes the specified object, including those of generic types, into its
* equivalent representation as a tree of {@link JsonElement}s. This method must be used if the
* specified object is a generic type. For non-generic objects, use {@link #toJsonTree(Object)}
* instead.
*
* @param src the object for which JSON representation is to be created
* @param typeOfSrc The specific genericized type of src. You can obtain
* this type by using the {@link TypeToken} class. For example,
* to get the type for {@code Collection<Foo>}, you should use:
* <pre>
* Type typeOfSrc = new TypeToken<Collection<Foo>>(){}.getType();
* </pre>
* @return Json representation of {@code src}
* @since 1.4
*/
public JsonElement toJsonTree(Object src, Type typeOfSrc) {
JsonTreeWriter writer = new JsonTreeWriter();
toJson(src, typeOfSrc, writer);
return writer.get();
}
示例10: toJsonTree
import com.google.gson.internal.bind.JsonTreeWriter; //导入依赖的package包/类
/**
* This method serializes the specified object, including those of generic types, into its
* equivalent representation as a tree of {@link JsonElement}s. This method must be used if the
* specified object is a generic type. For non-generic objects, use {@link #toJsonTree(Object)}
* instead.
*
* @param src the object for which JSON representation is to be created
* @param typeOfSrc The specific genericized type of src. You can obtain
* this type by using the {@link com.google.gson.reflect.TypeToken} class. For example,
* to get the type for {@code Collection<Foo>}, you should use:
* <pre>
* Type typeOfSrc = new TypeToken<Collection<Foo>>(){}.getType();
* </pre>
* @return Json representation of {@code src}
* @since 1.4
*/
public JsonElement toJsonTree(Object src, Type typeOfSrc) {
JsonTreeWriter writer = new JsonTreeWriter();
toJson(src, typeOfSrc, writer);
return writer.get();
}