import com.alibaba.fastjson.JSONArray;
import java.util.HashMap;
import java.util.Map;
public class Test2 {
public static void main(String args[]){
String name = "实体商品";
Map<String, String> map = new HashMap<>();
map.put("contentName",name);
map.put("name",name);
Object obj = JSONArray.toJSON(map);
String json = obj.toString();
System.out.println("将Map<String,String>转成json:" + json);
}
}
结果输出: