Package org.springside.modules.utils.encode

Examples of org.springside.modules.utils.encode.JsonBinder


   * 测试三种不同的Binder.
   */
  @Test
  public void threeTypeBinders() {
    //打印全部属性
    JsonBinder normalBinder = JsonBinder.buildNormalBinder();
    TestBean bean = new TestBean("A");
    assertEquals("{\"nullValue\":null,\"name\":\"A\",\"defaultValue\":\"hello\"}", normalBinder.toJson(bean));

    //不打印nullValue属性
    JsonBinder nonNullBinder = JsonBinder.buildNonNullBinder();
    assertEquals("{\"name\":\"A\",\"defaultValue\":\"hello\"}", nonNullBinder.toJson(bean));

    //不打印默认值未改变的nullValue与defaultValue属性
    JsonBinder nonDefaultBinder = JsonBinder.buildNonNullBinder();
    assertEquals("{\"name\":\"A\"}", nonDefaultBinder.toJson(bean));
  }
View Full Code Here

TOP

Related Classes of org.springside.modules.utils.encode.JsonBinder

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.