Package org.auto.json

Examples of org.auto.json.JsonArray


  /** ~~~~~~~~~~~~~~~~~~~~~~~推送消息~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
  /**
   * 将消息用指定的writer发送
   * */
  private void pushMessage(List<String> messages, PrintWriter writer) {
    JsonArray array = new JsonArray();
    boolean isClose = false;
    for (String message : messages) {
      if (isCloseMessage(message)) {
        isClose = true;
      }
      array.add(message);
    }
    writer.write(array.toString());
    writer.flush();
    // 如果发送的消息中有关闭消息,则真正关闭连接
    if (isClose) {
      reallyClose();
    }
View Full Code Here


  }

  public static void testJson() {
    JsonSerializer jsonSerializer = new JsonSerializer();

    JsonArray array = new JsonArray();
    Person person = new Person();
    person.setAge(23);
    Person person1 = new Person();
    person1.setName("haha");
    person.setPerson(person1);

    array.add(person);
    array.add(4);
    array.add("this is a String");
    array.add('c');
    array.add(true);
    array.add(null);
    JsonObject jsonObject = new JsonObject();
    jsonObject.put("name", "hehe");
    jsonObject.put("sdf", new JsonObject());
    jsonObject.put("khiyiu", null);
    array.add(jsonObject);
    array.add(new JsonObject());

    String jsonString = jsonSerializer.toJsonString(person);

    JsonDeserializer deserializer = new JsonDeserializer();
    Person dperson = (Person) deserializer.toObject(jsonString,
View Full Code Here

TOP

Related Classes of org.auto.json.JsonArray

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.