JSON数据-FastJson的使用



1.导包

<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
    <groupId>com.alibaba</groupId>
    <artifactId>fastjson</artifactId>
    <version>1.2.78</version>
</dependency>



 @RequestMapping("/j4")
    public String jason4() {

        List<User> userList=new ArrayList<User>();
        User user1 = new User(1, "邓孝慈", "111111");
        User user2 = new User(1, "许魏洲", "2222");
        User user3 = new User(1, "卡卡", "123456");
        userList.add(user1);
        userList.add(user2);
        userList.add(user3);

        String s = JSON.toJSONString(userList);
        return s;

    }

posted @ 2022-01-14 14:50  卡卡发  阅读(40)  评论(0)    收藏  举报