Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1058 Improve performance of RenderJson #1059

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions framework/src/play/mvc/results/RenderJson.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@
*/
public class RenderJson extends Result {

private static final Gson GSON = new Gson();

private final String json;

public RenderJson(Object o) {
json = new Gson().toJson(o);
json = GSON.toJson(o);
}

public RenderJson(Object o, Type type) {
json = new Gson().toJson(o, type);
json = GSON.toJson(o, type);
}

public RenderJson(Object o, JsonSerializer<?>... adapters) {
Expand All @@ -42,7 +44,7 @@ public RenderJson(Object o, Gson gson) {
if (gson != null) {
json = gson.toJson(o);
} else {
json = new Gson().toJson(o);
json = GSON.toJson(o);
}
}

Expand Down