-
Map转JSON
Map<String, Object> map = new HashMap<String, Object>(); map.put("username", "yaomy"); map.put("password", "123"); JSONObject json = new JSONObject(map);
-
JSON转String
JSONObject json = new JSONObject(); json.put("username", "yaomy"); json.put("password", "123"); json.toString();
-
JSON转Map
JSONObject json = new JSONObject(); json.put("username", "yaomy"); json.put("password", "123"); Map<String, Object> map = (Map<String, Object>)json;
-
String转JSON
String str = "{\"username\":\"yaomy\",\"password\":\"123\"}"; JSONObject json = JSONObject.parseObject(str);
转自:https://blog.csdn.net/yaomingyang/article/details/80252258(侵删)
Java中fastjson库将Map、JSON、String相互转换
最新推荐文章于 2024-07-21 22:27:18 发布