Created
October 6, 2012 08:39
-
-
Save MaySnow/3844409 to your computer and use it in GitHub Desktop.
Gson
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public String showJson() throws IOException { | |
user = new User(); | |
user.setId(1001); | |
user.setPassword("000000"); | |
user.setUsername("tom"); | |
response.setContentType("application/json;charset=UTF-8"); | |
Gson gson = new Gson(); | |
PrintWriter out = response.getWriter(); | |
out.print(gson.toJson(user)); | |
out.flush(); | |
out.close(); | |
return null; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment