I have basically used some mainstream json, such as jackson, gson, fastjson, etc. Personally, I still prefer fastjson. The performance may not be as good as jackson. Spring also uses jackson internally, but the API of fastjson is very simple and clean. json, I really like it
Google’s gson is also very useful
1. Import Json processing related jar packages
2. Use JSONObject encapsulation
So the function can be simply written like this:
fastjson produced by Alibaba,
JSONObject json = new JSONObject(); json.put("contractCode","2017021001")
return json.toJSONString();
Use gson, convenient and easy to use
If it is a maven project, you can use fastjson
to introduce dependencies
I have basically used some mainstream json, such as jackson, gson, fastjson, etc. Personally, I still prefer fastjson. The performance may not be as good as jackson. Spring also uses jackson internally, but the API of fastjson is very simple and clean. json, I really like it