HashMap 转 Json

<dependency>
   <groupId>com.alibaba</groupId>
   <artifactId>fastjson</artifactId>
   <version>1.2.24</version>
</dependency>



Map map=new HashMap();
map.put("page_size","10");
map.put("page_index","1");
String  param= JSON.toJSONString(map);




	    
Map<String, Object> resultMap = new HashMap<>();
     resultMap.put("type", type);
    resultMap.put("id", 10);
    resultMap.put("name", "name");
     JSONArray jArray = new JSONArray();
    jArray.put(resultMap);
    String str = jArray.toString();

  

posted @ 2019-04-28 16:01  DebuGger丶  阅读(6631)  评论(0)    收藏  举报