FastJSON JSONObject 字段排序 Feature.OrderedField
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;
}
}
FastJSON JSONObject 字段排序 Feature.OrderedField的更多相关文章
- Java 多字段排序Comparator(兼容Date,Integer,Doubel,Long)
Java 反射类:ReflexUtil public class ReflexUtil { static Logger logger = LoggerFactory.getLogger(ReflexU ...
- No message body writer has been found for class com.alibaba.fastjson.JSONObject, ContentType: */*
1:当使用 cxf 发布服务时,要求返回值类型为xml,或者json等 @Path("/searchProductByText") @GET @Produces({"ap ...
- net.sf.json.JSONOBJECT.fromObject 与 com.alibaba.fastjson.JSONObject.parseObject
文章待补充,先写写以下知识点好了. NULL值处理之 net.sf.json.JSONObject 和 com.alibaba.fastjson.JSONObject区别 JSON作为一个轻量级的文本 ...
- PHP 二维数组根据某个字段排序
二维数组根据某个字段排序有两种办法,一种是通过sort自己写代码,一种是直接用array_multisort排序函数 一. 手写arraysort PHP的一维数组排序函数: sort 对数组的值按 ...
- 对文本行按特定字段排序(前N个字符或后N个字符),TCPL 练习5-17
The C programming language 的关于文本行排序的问题有很多种要求的方式,在对每行的字段排序方面,最简单的是例如对前N个字符或者末位N个字符进行排序,更高一点的要求是,对特殊符号 ...
- php 数组排序以及按照某个字段排序
经常,开发人员发现在PHP中使用这种数据结构对值或者数组元素进行排序非常有用.PHP提供了一些适合多种数组的排序函数,这些函数允许你在数组内部对元素进行排列,也允许用很多不同的方法对它们进行重新排序. ...
- Entity Framework 4、5 多字段排序
public interface IOrderByExpression<TEntity> where TEntity : class { IOrderedQueryable<TEnt ...
- LINQ 按多个字段排序
多字段排序 添加到 LINQ 查询结果中的Take()扩展方法用于提取前 个结果: private static void Ordering() { var racers = (from r in F ...
- [wordpress]根据自定义字段排序并根据自定义字段查询
Wordpress中,根据根据自定义字段排序和查询是通过WP_Query()方法 如根据 一个自定义的sort的数字字段从小到大进行排序 $args = array( 'post_type' => ...
随机推荐
- svn 版本控制搭建
1.安装SVN yum install subversion 2.开启服务 systemctl start svnserve.service 3.创建仓库 svnadmin create /opt/s ...
- SecureCRT 使用密钥登录 Ubuntu
记录 SecureCRT 通过 SSH 使用密钥登录 Ubuntu. 具体步骤如下: 1. 使用 SecureCRT 生成密钥对: 工具 -> 创建公钥 -> 密钥类型 RSA -> ...
- USACO19DEC题解
Bronze A Cow Gymnastics 题目:https://www.luogu.com.cn/problem/P5831 题解:用数组存一下出现位置,O(n^2)枚举一下就好. 代码: #i ...
- 【转帖】从 Oracle 到 PostgreSQL ,某保险公司迁移实践 技术实践
从 Oracle 到 PostgreSQL ,某保险公司迁移实践 http://www.itpub.net/2019/11/08/4108/ 信泰人寿保险股份有限公司 摘要:去O一直是金融保险行业永恒 ...
- Prometheus入门到放弃(7)之redis_exporter部署
redis监控,prometheus需要使用redis_exporter客户端. 这里我们采用docker方式部署,既可以部署在redis所在服务器,也可以部署在其他机器: docker镜像地址:ht ...
- Linux 总结篇
1. sudo -i update upgrade install 包名 (openjdk-8-jdk) autoremove 自动删除不需要的包(remove卸载) sudo apt-get 2. ...
- 【IDEA使用技巧】(3) —— IntelliJ IDEA Maven配置
1.IntelliJ IDEA Maven配置 1.1. Maven介绍与下载 Maven是一个项目管理工具,使用它能对Java项目中的jar包进行管理与项目构建,很好地解决了传统项目使用导包的方式管 ...
- 【C#】上机实验五
.设计一个控制台应用程序,定义一个MyPoint类,该类能表示二维平面空间的点,完成点类及运算符重载等相关功能.具体要求如下: ()MyPoint类中定义2个私有字段x和y及相应的构造函数. ()My ...
- mysql中常见正则表达式的应用
查找name字段中以'st'为开头的所有数据: mysql> SELECT name FROM person_tbl WHERE name REGEXP '^st'; 查找name字段中以'ok ...
- How to read request body in a asp.net core webapi controller?
原文 How to read request body in a asp.net core webapi controller? A clearer solution, works in ASP.Ne ...