Create josn Array in java Servlet using JSON
This question already has an answer here:
its Very easy actually. Use Google gson.jar
Either you download From Here Download Google GSON Jar OR add dependencies( if Your Project is Maven ) to your pom.xml
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.2.2</version>
</dependency>
and try this Link GSON Serializer Example
Note :- This is just a reference code. You can Implement at your own way as per your Need. Thank You
Create a POJO which represents your JSON object. Top object containing list of second object. Use jackson or xstream to marshal Java object into Json and write the json string onto servlet response.
链接地址: http://www.djcxy.com/p/46062.html