javaBean转为json

一个测试用例

javabean转json

    @Test
    @Rollback(false)
    public void policyQueryTest() throws Exception {
        // 查询数据
        String id = "402892816136971701613699f23f0002";
        DmPolicy tem = policyService.queryPolicy(id);
        System.out.println("1111111111111111111111111111111111111111111111111111");
        ObjectMapper mapper = new ObjectMapper();
//javabean转json String jsonString
= mapper.writeValueAsString(tem); System.out.println(jsonString); System.out.println("1111111111111111111111111111111111111111111111111111"); } }

 json转 javabean

DmPolicy zz = mapper.readValue(jsonString, DmPolicy.class);

 

posted @ 2018-02-02 14:04  袁骞骞  阅读(691)  评论(0编辑  收藏  举报