package com.test.springboot.utils; import com.alibaba.fastjson.JSONObject; import java.util.HashMap; import java.util.Map; public class Test { public static void main(String[] args) { Map<String, Object> param = new HashMap<>(16); param.put("account", "12345678"); param.put("appKey", "ios"); String jsonStr = JSONObject.toJSONString(param); System.out.println(jsonStr); } }
执行示例: