网站首页
Java
站长
开源
框架
理论
JS
Linux
DB
服务器
网络编程
生活
软件
PHP
其他
回复java小强

再放一段Array和Map的示例代码: public static void array2JSON() {     String[] arr_String = { "a", "b", "c" };     String json_arr_String = JSON.toJSONString(arr_String, true);     System.out.println(json_arr_String);     JSONArray jsonArray = JSON.parseArray(json_arr_String);     for (Object o : jsonArray) {         System.out.println(o);     }     System.out.println(jsonArray); } public static void array2JSON2() {     Bar[] arr_Bar = { new Bar(), new Bar(), new Bar() };     String json_arr_Bar = JSON.toJSONString(arr_Bar, true);     System.out.println(json_arr_Bar);     JSONArray jsonArray = JSON.parseArray(json_arr_Bar);     for (Object o : jsonArray) {         System.out.println(o);     }     System.out.println(jsonArray); } public static void map2JSON() {     Map map = new HashMap();     map.put("a", "aaa");     map.put("b", "bbb");     map.put("c", "ccc");     String json = JSON.toJSONString(map);     System.out.println(json);     Map map1 = JSON.parseObject(json);     for (Object o : map.entrySet()) {         Map.Entry<String, String> entry = (Map.Entry<String, String>) o;         System.out.println(entry.getKey() + "--->" + entry.getValue());     } }

您的网名:
个人主页:
编辑内容: