How to put an object into json data?

Creative Commons License Copyright: Attribution, allow others to create paper-based, and must distribute paper (based on the original license agreement with the same license Creative Commons )

first step:

Download json depends basic package. I have uploaded to the csdn resources download.

Step two: the core code

   ObjectMapper objectMapper = new ObjectMapper();
   String s = objectMapper.writeValueAsString(map);  //这里的map是你从后台接收不同的数据类型的集合

This three lines of code to be (user object type, List <user> object type, map <String, User> object type, map <String, List <User > object type) data can be converted into json types of data. (Json type data types: https://blog.csdn.net/longyanchen/article/details/93383099 , I have described in detail in a previous blog).

 

 

 

Guess you like

Origin blog.csdn.net/longyanchen/article/details/93385227