zoukankan      html  css  js  c++  java
  • fastjson的使用

     1 public static void main(String[] args) {
     2         // json演示序列化和反序列化
     3         User user = new User(0,"测试","0000",1);
     4         String str = JSON.toJSONString(user);
     5         System.out.println(str);
     6         String str1 = "{"uid":1,"uname":"发序列化","pwd":"123","iAdmin":1,}";
     7         User userF = JSON.parseObject(str1, User.class);
     8         System.out.println(userF.getUname());
     9         User user1 = new User(0, "测试1", "1234", 0);
    10         User user2 = new User(0, "测试2", "1234", 0);
    11         User user3 = new User(0, "测试3", "1234", 0);
    12         User user4 = new User(0, "测试4", "1234", 0);
    13         User user5 = new User(0, "测试5", "1234", 0);
    14         User user6 = new User(0, "测试6", "1234", 0);
    15         User user7 = new User(0, "测试7", "1234", 0);
    16         User user8 = new User(0, "测试8", "1234", 0);
    17         List<User> list = new ArrayList<>();
    18         list.add(user1);
    19         list.add(user2);
    20         list.add(user3);
    21         list.add(user4);
    22         list.add(user5);
    23         list.add(user6);
    24         list.add(user7);
    25         list.add(user8);
    26         String arryF = "[{"uid":0,"isAdmin":0,"pwd":"1234","uname":"测试1"},{"uid":0,"isAdmin":0,"pwd":"1234","uname":"测试2"},{"uid":0,"isAdmin":0,"pwd":"1234","uname":"测试3"},{"uid":0,"isAdmin":0,"pwd":"1234","uname":"测试4"},{"uid":0,"isAdmin":0,"pwd":"1234","uname":"测试5"},{"uid":0,"isAdmin":0,"pwd":"1234","uname":"测试6"},{"uid":0,"isAdmin":0,"pwd":"1234","uname":"测试7"},{"uid":0,"isAdmin":0,"pwd":"1234","uname":"测试8"}]
    " + 
    27                 "";
    28         System.out.println(JSON.toJSON(list));
    29         List<User> list2 = JSON.parseArray(arryF, User.class);
    30         for(User u:list2) {
    31             System.out.println(u.getUname());
    32         }
    33     }
  • 相关阅读:
    bootstrap-table实现分页、导出数据至excel
    Python求多个list的交集、并集、差集 & list 排序
    JS
    python 格式化输出(% VS format)
    pyqt5_实例:修改xml文件中节点值
    博客迁移
    Reverse is Multiplex, You Need PinTools.
    ISCC2018_leftleftrightright-Writeup
    如何在linux主机上运行/调试 arm/mips架构的binary
    强网杯2018
  • 原文地址:https://www.cnblogs.com/lingdu9527/p/11041734.html
Copyright © 2011-2022 走看看