alibabaFastJson之json转指定List
发表于|更新于
|浏览量:
有一种健忘是高贵的,就是不记旧恶。——赛蒙兹
之前写了篇fastjson基本使用,这两天遇到一个意料之外的
需要把一个json的数组对象,转换成指定的List<User>
转换方式很简单
{“code”:200,”userList”:[{“password”:”achao”,”username”:”ruben”}],”data”:”操作成功!”,”list”:[“你好”,”加油”],”success”:true}
1 | JSONObject jsonObject = JSON.parseObject(jsonString); |
打印结果

相关推荐
2024-02-17
网页运行java程序cheerpj
不清不见尘,不高不见危。——王尘 分享一个在网页上运行java应用的框架 https://labs.leaningtech.com/cheerpj3/getting-started/Java-app 首先按照提示下载TextDemo.jar,这是一个GUI程序,然后编写html 1234567891011121314151617<!doctype html><html lang="en"> <head> <meta charset="utf-8" /> <title>CheerpJ test</title> <script src="https://cjrtnc.leaningtech.com/3.0/cj3loader.js"></script> </head> <body> <script> (async function () { ...
2020-12-22
springbootTest坑
人一能之,己百之;人十能之,己千之。——《中庸》 今天踩到一个坑,使用springboot单元测试时插入数据回滚了 最后发现原来需要在测试类上面加上@Rollback(false)就可以了 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960package com.ruben;/** * @ClassName: MybatisPlusDemo * @Date: 2020/11/9 0009 20:51 * @Description: */import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;import com.baomidou.mybatisplus.core.metadata.IPage;import com.baomidou.mybatisplus.core.toolkit.Wrappers;import co...
2023-12-26
docker运行seata
怀疑一切与信任一切是同样的错误,能得乎其中方为正道。——乔叟 https://hub.docker.com/r/seataio/seata-server 命令: 1docker run --name seata-server -p 8091:8091 -p 7091:7091 seataio/seata-server:latest 自定义配置文件: 123456docker run --name seata-server \ -p 8091:8091 \ -p 7091:7091 \ -e SEATA_CONFIG_NAME=file:/root/seata-config/registry \ -v /PATH/TO/CONFIG_FILE:/root/seata-config \ seataio/seata-server 指定ip 12345docker run --name seata-server \ -p 8091:8091 \ -p 7091:7091 \ ...
2020-08-13
fastjson基本使用
alibaba的fastjson真香啊 首先是依赖 123456<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson --><dependency> <groupId>com.alibaba</groupId> <artifactId>fastjson</artifactId> <version>1.2.73</version></dependency> 这里列举点简单的应用 首先是对象转JSON 1234567Map<String, Object> map = new HashMap<>(1 << 3);map.put("data", "操作成功!");map.put("code", 200);map.put("success", true);map.put("...
2020-11-03
使用@Select注解写<foreach>
智慧是宝石,如果用谦虚镶边,就会更加灿烂夺目。——高尔基 只需要加<sceipt>标签就可以了 1234567@Select({"<script>" + "select * from user where id in " + "<foreach item = 'id' index = 'index' collection = 'list' open='(' separator=',' close=')'>" + "#{id}" + "</foreach>" + "</script>"})List<User> selectU...
2021-05-07
SHA1加密
谎言说得越来越真诚,最终连她自己也从中得到了安慰。——《百年孤独》 方式很简单,无需引入外部依赖 123456789101112131415161718192021222324import java.nio.charset.StandardCharsets;import java.security.MessageDigest;import java.security.NoSuchAlgorithmException;class Scratch { public static void main(String[] args) { System.out.println(getSha1("我的世界")); } public static String getSha1(String input) { MessageDigest mDigest = null; try { mDigest = MessageDigest.getInsta...

阿超
我的名字叫阿超 年龄25岁 家在北京市 职业是软件开发 每天最晚也会在八点前回家 不抽烟 酒浅尝辄止 晚上十二点上床 保证睡足八个小时 睡前写一篇博客 再做二十分钟俯卧撑暖身 然后再睡觉 基本能熟睡到天亮 像婴儿一样不留下任何疲劳和压力 就这样迎来第二天的早晨 健康检查结果也显示我很正常 我想说明我是一个不论何时都追求内心平稳的人 不拘泥于胜负 不纠结于烦恼 不树立使我夜不能寐的敌人 这就是我在这社会的生活态度
Follow Me公告
This is my Blog