Essential Android Fastjson edit forum

Convert the data of type Map to JSON String

Code

Group group = new Group();  
group.setId(1);  
group.setName("Ke");  
  
User user1 = new User();  
user1.setId(2);  
user1.setName("Liu");
User user2 = new User();  
user2.setId(3);  
user2.setName("Yue");  
group.getList().add(user1);  
group.getList().add(user2);  
  
Map<Integer, Object> map = new HashMap<Integer,Object>();  
map.put(1, "No.1");  
map.put(2, "No.2");  
map.put(3, group.getList());  
  
String jsonString = JSON.toJSONString(map);  
System.out.println(jsonString);

Output

{1:"No.1",2:"No.2",3:[{"id":2,"name":"Liu"},{"id":3,"name":"Yue"}]}
Fastjson/
Fastjson
Parsing JSON with Fastjson
Convert the data of type Map to JSON String

Table Of Contents
39 ACRA
64 Menu
112 Loader
119 Xposed
132 Colors
135 Fresco
140 AdMob
147 Button
156 Vk SDK
170 XMPP
176 OpenCV
200 FileIO
203 Moshi
217 Paint
231 AIDL
241 JCodec
243 Okio
255 Looper
262 Fastjson
  ↑ ↓ to navigate     ↵ to select     Esc to close