Android JsonTreeWriter - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android JsonTreeWriter class.

This code example shows how to use the following methods:setLenient
   * @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);
    } 
  } 
 
  /** 
   * Reads one JSON value (an array, object, string, number, boolean or null) 
   * and converts it to a Java object. Returns the converted object. 
   * 
   * @return the converted Java object. May be null. 
   */ 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:get
   * </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();
  } 
 
  /** 
   * This method serializes the specified object into its equivalent Json representation. 
   * This method should be used when the specified object is not a generic type. This method uses 
   * {@link Class#getClass()} to get the type for the specified object, but the 
   * {@code getClass()} loses the generic type information because of the Type Erasure feature 
   * of Java. Note that this method works fine if the any of the object fields are of generic type, 
   * just the object itself should not be of a generic type. If the object is of generic type, use 
   * {@link #toJson(Object, Type)} instead. If you want to write out the object to a 
   * {@link Writer}, use {@link #toJson(Object, Appendable)} instead. 
   * 
2
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Android JsonTreeWriter Methods: