FastJSON JSONObject 字段排序 Feature.OrderedField
2024-10-19 21:35:00
package cn.tongdun.robot.web; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.parser.Feature; import java.util.List; /**
* @author hello
* @date 2019-10-18 13:46
* @description
*/
public class Hello {
public static void main(String[] args) {
String str = "[\n" +
" {\n" +
" \"type\": \"SEND\",\n" +
" \"dataMapping\": {\n" +
" \"userid\": \"account\",\n" +
" \"ts\": \"ts\",\n" +
" \"sign\": \"sign\",\n" +
" \"mobile\": \"taskItem.mobile\",\n" +
" \"msgcontent\": \"taskItem.content\",\n" +
" \"time\": \"taskItem.scheduleTime\",\n" +
" \"URL\": \"http://1.1.1.1:8081/api/sms/send\",\n" +
" \"password\": \"password\"\n" +
" },\n" +
" \"maxSendCount\": \"1000\",\n" +
" \"tps\": \"50\",\n" +
" \"channelPattern\": \"JSON\",\n" +
" \"sendSeparate\": \"\",\n" +
" \"httpHeaderParams\": {\n" +
" \"Authorization\": \"authorization\"\n" +
" }\n" +
" },\n" +
" {\n" +
" \"type\": \"REPORT\",\n" +
" \"dataMapping\": {\n" +
" \"userid\": \"account\",\n" +
" \"ts\": \"ts\",\n" +
" \"sign\": \"sign\",\n" +
" \"password\": \"password\",\n" +
" \"URL\": \"http://1.1.1.1/api/v2/sms/query\"\n" +
" },\n" +
" \"tps\": \"10\",\n" +
" \"channelPattern\": \"JSON\"\n" +
" }\n" +
"]"; // Object list = JSON.parse(str, Feature.OrderedField); List<HelloBean> list = JSON.parseObject(str, new TypeReference<List<HelloBean>>() {}.getType(), Feature.OrderedField);
System.out.println(list);
}
}
package cn.tongdun.robot.web; import com.alibaba.fastjson.JSONObject; /**
* @author hello
* @date 2019-10-18 14:29
* @description
*/
public class HelloBean { /**
* type : REPORT
* dataMapping : {"userid":"account","ts":"ts","sign":"sign","password":"password","URL":"http://47.99.224.177:8081/api/v2/sms/query"}
* tps : 10
* channelPattern : JSON
*/ private String type;
private JSONObject dataMapping;
private String tps;
private String channelPattern; public String getType() {
return type;
} public void setType(String type) {
this.type = type;
} public JSONObject getDataMapping() {
return dataMapping;
} public void setDataMapping(JSONObject dataMapping) {
this.dataMapping = dataMapping;
} public String getTps() {
return tps;
} public void setTps(String tps) {
this.tps = tps;
} public String getChannelPattern() {
return channelPattern;
} public void setChannelPattern(String channelPattern) {
this.channelPattern = channelPattern;
}
}
最新文章
- Javascript中的valueOf与toString
- thinkphp5命名规范
- UVA 11076 - Add Again(组合)
- ubuntu安装Python环境以及科学计算环境
- 本地缺Android SDK版本20,Unable to resolve target &#39;android-20&#39;
- 跟开涛老师学shiro -- shiro简介
- 黄聪:wordpress如何添加自定义文章快速编辑按钮
- Android核心分析之十八Android电话系统之RIL-Java
- UnitTest
- 深入理解Python中的生成器
- 高清摄像头MIPI接口与ARM处理器的连接
- webuploader文件上传问题总结
- mybatis拦截器分页
- Bootstrap入门(二十)组件14:警告框
- iBatis一些非见用法(相当实用)
- rem ~~ 你懂了吗?
- Spring源码工程导入Eclsipse缺少两个jar文件
- [Swift]LeetCode349. 两个数组的交集 | Intersection of Two Arrays
- Appium日志乱码终结指北
- cocos2dx2.x&;3.x部分函数对照表
热门文章
- robot:当用例失败时执行关键字(发送短信)
- Spring Boot拦截器实现并和swagger集成后使用拦截器的配置问题
- Saltack 针对用户进行权限控制
- mac远程连接linux 服务器桌面by VNC
- 【转帖】从 Oracle 到 PostgreSQL ,某保险公司迁移实践 技术实践
- Apache Kafka + Spark Streaming Integration
- Educational Codeforces Round 71
- 【LEETCODE】50、数组分类,简单级别,题目:888,1013,896,485,448,697
- 小贴士--Python
- Helm命令帮助参数