Skip to content

Commit

Permalink
Prettified output
Browse files Browse the repository at this point in the history
  • Loading branch information
xwillq committed May 7, 2020
1 parent be17d88 commit 61a9460
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,8 @@ import com.google.gson.GsonBuilder
import com.google.inject.Provider

class GSONProvider : Provider<Gson> {
override fun get() : Gson = GsonBuilder().excludeFieldsWithoutExposeAnnotation().create()
override fun get() : Gson = GsonBuilder()
.excludeFieldsWithoutExposeAnnotation()
.setPrettyPrinting()
.create()
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class ActivityServlet: HttpServlet() {
val gson = gsonProvider.get()
val json = gson.toJson(activityList)

response.contentType = "text/plain"
response.writer.print(json)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ class AuthorityServlet: HttpServlet() {
val gson = gsonProvider.get()
val json = gson.toJson(authorityList)

response.contentType = "text/plain"
response.writer.print(json)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ class UserServlet: HttpServlet() {
logger.info("Converting users to json")
val gson = gsonProvider.get()
val json = gson.toJson(userList)


response.contentType = "text/plain"
response.writer.print(json)
}
}

0 comments on commit 61a9460

Please sign in to comment.