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的更多相关文章

  1. Java 多字段排序Comparator(兼容Date,Integer,Doubel,Long)

    Java 反射类:ReflexUtil public class ReflexUtil { static Logger logger = LoggerFactory.getLogger(ReflexU ...

  2. No message body writer has been found for class com.alibaba.fastjson.JSONObject, ContentType: */*

    1:当使用 cxf 发布服务时,要求返回值类型为xml,或者json等 @Path("/searchProductByText") @GET @Produces({"ap ...

  3. net.sf.json.JSONOBJECT.fromObject 与 com.alibaba.fastjson.JSONObject.parseObject

    文章待补充,先写写以下知识点好了. NULL值处理之 net.sf.json.JSONObject 和 com.alibaba.fastjson.JSONObject区别 JSON作为一个轻量级的文本 ...

  4. PHP 二维数组根据某个字段排序

    二维数组根据某个字段排序有两种办法,一种是通过sort自己写代码,一种是直接用array_multisort排序函数 一. 手写arraysort PHP的一维数组排序函数: sort  对数组的值按 ...

  5. 对文本行按特定字段排序(前N个字符或后N个字符),TCPL 练习5-17

    The C programming language 的关于文本行排序的问题有很多种要求的方式,在对每行的字段排序方面,最简单的是例如对前N个字符或者末位N个字符进行排序,更高一点的要求是,对特殊符号 ...

  6. php 数组排序以及按照某个字段排序

    经常,开发人员发现在PHP中使用这种数据结构对值或者数组元素进行排序非常有用.PHP提供了一些适合多种数组的排序函数,这些函数允许你在数组内部对元素进行排列,也允许用很多不同的方法对它们进行重新排序. ...

  7. Entity Framework 4、5 多字段排序

    public interface IOrderByExpression<TEntity> where TEntity : class { IOrderedQueryable<TEnt ...

  8. LINQ 按多个字段排序

    多字段排序 添加到 LINQ 查询结果中的Take()扩展方法用于提取前 个结果: private static void Ordering() { var racers = (from r in F ...

  9. [wordpress]根据自定义字段排序并根据自定义字段查询

    Wordpress中,根据根据自定义字段排序和查询是通过WP_Query()方法 如根据 一个自定义的sort的数字字段从小到大进行排序 $args = array( 'post_type' => ...

随机推荐

  1. 【curl】certificate is bad 问题解决

    参考:https://blog.scottlowe.org/2018/08/20/troubleshooting-tls-certificates/ 我最近正在写一篇博客文章,内容涉及使用TLS证书进 ...

  2. [LeetCode] 40. Combination Sum II 组合之和 II

    Given a collection of candidate numbers (candidates) and a target number (target), find all unique c ...

  3. laravel composer vendor 目录加载类库详细 之后做说明

    composer installLoading composer repositories with package informationInstalling dependencies (inclu ...

  4. [JAVA] maven 阿里云节点 settings.xml

    <?xml version="1.0" encoding="UTF-8"?> <settings xmlns="http://mav ...

  5. Pytorch1.3源码解析-第一篇

    pytorch$ tree -L 1 . ├── android ├── aten ├── benchmarks ├── binaries ├── c10 ├── caffe2 ├── CITATIO ...

  6. Get Docker Engine - Community for Ubuntu

    Get Docker Engine - Community for Ubuntu Uninstall old versions$ sudo apt-get remove docker docker-e ...

  7. Spring MVC 问题归纳

    记录一些在Spring MVC配置中出现的问题 一.配置tomcat包没有加载 错误: idea调试web项目时出现:java.lang.ClassNotFoundException:org.spri ...

  8. Java开发笔记(一百零八)JSON串的定义和解析

    前面提到URL尾巴支持添加请求参数,具体格式形如“参数A名称=A参数值&参数B名称=B参数值”,可是这种格式只能传递简单的键值对信息,不能传递结构化数据,也无法传递数组形式的参数,因而它不适用 ...

  9. python大道——博客目录

      python基础 第一章 计算机基础 计算机基础 第二章 python基础语法 python入门 第三章 基础数据类型和文件操作 整型.布尔.字符串 列表.字典.集合 公共功能.小数据池 hash ...

  10. 【转】基于FPGA的Sobel边缘检测的实现

    前面我们实现了使用PC端上位机串口发送图像数据到VGA显示,通过MATLAB处理的图像数据直接是灰度图像,后面我们在此基础上修改,从而实现,基于FPGA的动态图片的Sobel边缘检测.中值滤波.Can ...