Package org.codehaus.jettison.json

Examples of org.codehaus.jettison.json.JSONStringer


  /** Test if toString generates real JSON */
  @Test
  public void testToString() throws JSONException {
    SchemaConfigured sc = new SchemaConfigured(null, TABLE_NAME, CF_NAME);
    JSONStringer json = new JSONStringer();
    json.object();
    json.key("tableName");
    json.value(TABLE_NAME);
    json.key("cfName");
    json.value(CF_NAME);
    json.endObject();
    assertEquals(json.toString(), sc.schemaConfAsJSON());
  }
View Full Code Here


  /**
   * Gets JSON string from a collection of goods or categories
   */
  private String getItemsJson(Iterable<? extends Jsonable<?>> items)
      throws JSONException {
    JSONStringer st = new JSONStringer();
    JSONWriter writer = st.array();
    for(Jsonable<?> i: items) {
      writer = writer.value(new JSONObject(i.toJson()));
    }
    writer = writer.endArray();
   
View Full Code Here

    }
  }

  public String toJson() {
    try {
      JSONWriter writer = new JSONStringer().object();
      if(key != null) {
        writer = writer.key(Jsonable.KEY_STR).value(KeyFactory.keyToString(key));
      }
      JSONWriter value = writer
      .key(Category.NAME).value(getName())
View Full Code Here

TOP

Related Classes of org.codehaus.jettison.json.JSONStringer

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.