Package org.springside.modules.mapper

Examples of org.springside.modules.mapper.JsonMapper.fromJson()


    // 使用enum.toString(), 注意配置必須在所有讀寫動作之前調用.
    // 建议toString()使用index数字属性,比enum.name()节约了空间,比enum.order()则不会有顺序随时改变不确定的问题。
    JsonMapper newMapper = new JsonMapper();
    newMapper.enableEnumUseToString();
    assertThat(newMapper.toJson(TestEnum.One)).isEqualTo("\"1\"");
    assertThat(newMapper.fromJson("\"1\"", TestEnum.class)).isEqualTo(TestEnum.One);
  }

  /**
   * 枚舉類型的演示Bean.
   */
 
View Full Code Here


    String jsonString = newMapper.toJson(user);

    assertThat(jsonString).isEqualTo("{\"name\":\"foo\",\"salary\":\"1.2\"}");

    // from
    User resultUser = newMapper.fromJson(jsonString, User.class);
    assertThat(resultUser.getSalary().value).isEqualTo(1.2);

  }

  public class MoneySerializer extends StdSerializer<Money> {
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.