Java 类com.google.gson.internal.bind.JsonTreeWriter 实例源码

项目:letv    文件:TypeAdapter.java   
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);
    }
}
项目:odoo-work    文件:TypeAdapter.java   
/**
 * 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);
  }
}
项目:lams    文件:TypeAdapter.java   
/**
 * 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);
  }
}
项目:boohee_v5.6    文件:TypeAdapter.java   
public final JsonElement toJsonTree(T value) {
    try {
        JsonTreeWriter jsonWriter = new JsonTreeWriter();
        write(jsonWriter, value);
        return jsonWriter.get();
    } catch (Throwable e) {
        throw new JsonIOException(e);
    }
}
项目:odoo-follow-up    文件:TypeAdapter.java   
/**
 * 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);
  }
}
项目:MyJojoXUtils    文件:TypeAdapter.java   
/**
 * 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);
  }
}
项目:SteamLib    文件:TypeAdapter.java   
/**
 * 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);
  }
}
项目:1797-2017    文件:TypeAdapter.java   
/**
 * 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);
  }
}
项目:1797-2017    文件:TypeAdapter.java   
/**
 * 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);
  }
}
项目:urmusic-desktop    文件:TypeAdapter.java   
/**
 * 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);
  }
}
项目:MiBandDecompiled    文件:TypeAdapter.java   
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;
}
项目:android-http-lib-based-on-volley    文件:TypeAdapter.java   
/**
 * 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);
  }
}
项目:reflect-app    文件:TypeAdapter.java   
/**
 * 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);
  }
}
项目:androidsummary    文件:TypeAdapter.java   
/**
 * 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);
  }
}
项目:Edge-Node    文件:TypeAdapter.java   
/**
 * 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);
  }
}
项目:BungeeSigns    文件:TypeAdapter.java   
/**
 * 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);
  }
}
项目:multicraft-api    文件:TypeAdapter.java   
/**
 * 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);
  }
}
项目:StaticMC    文件:TypeAdapter.java   
/**
 * 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);
  }
}
项目:gson    文件:TypeAdapter.java   
/**
 * 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);
  }
}
项目:letv    文件:Gson.java   
public JsonElement toJsonTree(Object src, Type typeOfSrc) {
    JsonWriter writer = new JsonTreeWriter();
    toJson(src, typeOfSrc, writer);
    return writer.get();
}
项目:boohee_v5.6    文件:Gson.java   
public JsonElement toJsonTree(Object src, Type typeOfSrc) {
    JsonWriter writer = new JsonTreeWriter();
    toJson(src, typeOfSrc, writer);
    return writer.get();
}
项目:MiBandDecompiled    文件:Gson.java   
public JsonElement toJsonTree(Object obj, Type type)
{
    JsonTreeWriter jsontreewriter = new JsonTreeWriter();
    toJson(obj, type, jsontreewriter);
    return jsontreewriter.get();
}
项目:odoo-work    文件:Gson.java   
/**
 * 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&lt;Collection&lt;Foo&gt;&gt;(){}.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();
}
项目:lams    文件:Gson.java   
/**
 * 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&lt;Collection&lt;Foo&gt;&gt;(){}.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();
}
项目:odoo-follow-up    文件:Gson.java   
/**
 * 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&lt;Collection&lt;Foo&gt;&gt;(){}.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();
}
项目:MyJojoXUtils    文件:Gson.java   
/**
 * 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&lt;Collection&lt;Foo&gt;&gt;(){}.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();
}
项目:SteamLib    文件:Gson.java   
/**
 * 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&lt;Collection&lt;Foo&gt;&gt;(){}.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();
}
项目:1797-2017    文件:Gson.java   
/**
 * 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&lt;Collection&lt;Foo&gt;&gt;(){}.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();
}
项目:1797-2017    文件:Gson.java   
/**
 * 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&lt;Collection&lt;Foo&gt;&gt;(){}.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();
}
项目:urmusic-desktop    文件:Gson.java   
/**
 * 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&lt;Collection&lt;Foo&gt;&gt;(){}.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();
}
项目:android-http-lib-based-on-volley    文件:Gson.java   
/**
 * 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&lt;Collection&lt;Foo&gt;&gt;(){}.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();
}
项目:reflect-app    文件:Gson.java   
/**
 * 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&lt;Collection&lt;Foo&gt;&gt;(){}.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();
}
项目:androidsummary    文件:Gson.java   
/**
 * 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&lt;Collection&lt;Foo&gt;&gt;(){}.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();
}
项目:Edge-Node    文件:Gson.java   
/**
 * 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&lt;Collection&lt;Foo&gt;&gt;(){}.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();
}
项目:BungeeSigns    文件:Gson.java   
/**
 * 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&lt;Collection&lt;Foo&gt;&gt;(){}.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();
}
项目:multicraft-api    文件:Gson.java   
/**
 * 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&lt;Collection&lt;Foo&gt;&gt;(){}.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();
}
项目:StaticMC    文件:Gson.java   
/**
 * 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&lt;Collection&lt;Foo&gt;&gt;(){}.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();
}
项目:gson    文件:Gson.java   
/**
 * 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&lt;Collection&lt;Foo&gt;&gt;(){}.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();
}