当前位置 : 主页 > 编程语言 > java >

fastjson key 排序

来源:互联网 收集:自由互联 发布时间:2021-06-28
gistfile1.txt package com.jiabing.fastjson;import java.util.HashMap;import java.util.Map;import com.alibaba.fastjson.JSON;import com.alibaba.fastjson.JSONObject;import com.alibaba.fastjson.serializer.SerializerFeature;public class TestJson
gistfile1.txt
package com.jiabing.fastjson;

import java.util.HashMap;
import java.util.Map;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;

public class TestJson {

	public static void main(String[] args) {
		Map
 
   map = new HashMap
  
   (); map.put("b", "cddd"); map.put("a", "cd"); map.put("f", "cd"); map.put("d", "cd"); String ss = JSON.toJSONString(map, SerializerFeature.MapSortField); System.out.println(ss); TestBean t = new TestBean("123", "654"); String sss = JSON.toJSONString(t, SerializerFeature.MapSortField); System.out.println(sss); } }
  
 
网友评论