Package org.springside.modules.utils.encode

Examples of org.springside.modules.utils.encode.JsonBinder.toJson()


  @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));
View Full Code Here


    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

    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
Copyright © 2018 www.massapi.com. 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.