E/lgq: httpheader----…222…{“name”:“{photoList=ssss, currentUser=zhang, success=true}”}
2、
–
对象转json
========
gson依赖;implementation ‘com.google.code.gson:gson:2.8.5’
json转对象
json转list
==========
生成任意格式的json数据
=============
private JSONObject createJSONObject() {
JSONObject result = new JSONObject();
result.put(“success”, true);
result.put(“totalCount”, “30”);
result.put(“okstatus”,okreString );
JSONObject user1 = new JSONObject();
user1.put(“id”, “12”);
user1.put(“name”, “张三”);
user1.put(“createTime”, “2017-11-16 12:12:12”);
JSONObject user2 = new JSONObject();
user2.put(“id”, “13”);
user2.put(“name”, “李四”);
user2.put(“createTime”, “2017-11-16 12:12:15”);
JSONObject department = new JSONObject();
department.put(“id”, 1);
department.put(“name”,“技术部”);
user1.put(“department”, department);
user2.put(“department”, department);
// 返回一个JSONArray对象
JSONArray jsonArray = new JSONArray();
jsonArray.add(0, user1);
jsonArray.add(1, user2);
result.element(“data”, jsonArray);
return result;
到此这篇map如何转json(map如何转list)的文章就 介绍到这了,更多相关内容请继续浏览下面的相关 推荐文章,希望大家都能在编程的领域有一番成就!版权声明:
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。
如若内容造成侵权、违法违规、事实不符,请将相关资料发送至xkadmin@xkablog.com进行投诉反馈,一经查实,立即处理!
转载请注明出处,原文链接:https://www.xkablog.com/qdvuejs/29116.html