json的string 转换为 map
json
适用于现代 C++ 的 JSON。
项目地址:https://gitcode.com/gh_mirrors/js/json
·
// [{"username":"admin","password":"admin"}]
Gson gson = new Gson();
Map<String, String> map = gson.fromJson(jsonListString, Map[].class)[0];
for (Object o : map.keySet()) {
System.out.println("key=" + o + " value=" + map.get(o));
}
// 将List<Map<String, String>>转换为JSON字符串
String jsonString = JSON.toJSONString(list);
System.out.println("JSON String: " + jsonString);
// 将JSON字符串转换回List<Map<String, String>>对象
List<Map<String, String>> deserializedList = JSON.parseObject(jsonString, List.class);
System.out.println("Deserialized List: " + deserializedList);
String jsonStr = "[{\"name\":\"张三\",\"id\":1},{\"name\":\"李四\",\"id\":2}]";
List<Map<String, Object>> resultList = JSON.parseObject(jsonStr, new TypeReference<List<Map<String, Object>>>() {});
适用于现代 C++ 的 JSON。
最近提交(Master分支:1 个月前 )
960b763e
4 个月前
8c391e04
7 个月前
更多推荐

所有评论(0)