Package org.auto.json

Examples of org.auto.json.JsonSerializer


    }

  }

  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,
        Person.class);

    System.out.println(jsonString);
    System.out.println(jsonSerializer.toJsonString(dperson));
  }
View Full Code Here

TOP

Related Classes of org.auto.json.JsonSerializer

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.