Package com.google.gson.internal.bind

Examples of com.google.gson.internal.bind.JsonTreeWriter


   * </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();
  }
View Full Code Here


   * </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();
  }
View Full Code Here

   * @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);
    }
  }
View Full Code Here

   * </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();
  }
View Full Code Here

    return toJsonTree(paramObject, paramObject.getClass());
  }

  public JsonElement toJsonTree(Object paramObject, Type paramType)
  {
    JsonTreeWriter localJsonTreeWriter = new JsonTreeWriter();
    toJson(paramObject, paramType, localJsonTreeWriter);
    return localJsonTreeWriter.get();
  }
View Full Code Here

  public final JsonElement toJsonTree(Object paramObject)
  {
    try
    {
      JsonTreeWriter localJsonTreeWriter = new JsonTreeWriter();
      write(localJsonTreeWriter, paramObject);
      return localJsonTreeWriter.get();
    }
    catch (IOException localIOException)
    {
      throw new JsonIOException(localIOException);
    }
View Full Code Here

   * </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();
  }
View Full Code Here

      super(delegate);
    }

    @Override
    public JsonWriter getWriter() {
      writer = new JsonTreeWriter();
      return writer;
    }
View Full Code Here

   * @param entity the entity to write
   * @param principal an optional Principal for access control
   * @return a json representation of the entity
   */
  public JsonElement append(HasUuid entity, Principal principal) throws IOException {
    JsonTreeWriter json = new JsonTreeWriter();
    packScope.enter()
        .withJsonWriter(json)
        .withPrincipal(principal)
        .withTraversalMode(TraversalMode.SPARSE);

    SerializationContext context = contexts.get();
    try {
      context.add(entity);
      visitorSupport.visit(writers.get(), entity);
      return json.get();
    } catch (Exception e) {
      context.fail(e);
      return null;
    } finally {
      packScope.exit();
View Full Code Here

   *
   * @param entity the entity to serialize
   * @return a json representation of the entity
   */
  public JsonElement pack(FlatPackEntity<?> entity) throws IOException {
    JsonTreeWriter json = new JsonTreeWriter();
    JsonElement toReturn;
    json.setSerializeNulls(false);
    packScope.enter().withEntity(entity).withJsonWriter(json);
    try {
      SerializationContext context = contexts.get();
      doPack(entity, context);
      toReturn = json.get();
      context.runPostWork();
      context.close();
    } finally {
      packScope.exit();
    }
View Full Code Here

TOP

Related Classes of com.google.gson.internal.bind.JsonTreeWriter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.