Unified JSON Formatter API
This commit is contained in:
@@ -36,7 +36,7 @@ public class JsonController implements RestController {
|
||||
try {
|
||||
Object requestJson = this.gson.fromJson(request.body(), Object.class);
|
||||
|
||||
responseJson.addProperty("data", this.prettyGson.toJson(requestJson));
|
||||
responseJson.addProperty("result", this.prettyGson.toJson(requestJson));
|
||||
responseJson.addProperty("time", System.currentTimeMillis() - startProcess);
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class JsonController implements RestController {
|
||||
|
||||
response.status(400);
|
||||
|
||||
responseJson.addProperty("data", cause == null ? e.getMessage() : cause.getMessage());
|
||||
responseJson.addProperty("result", cause == null ? e.getMessage() : cause.getMessage());
|
||||
responseJson.addProperty("time", System.currentTimeMillis() - startProcess);
|
||||
|
||||
|
||||
@@ -65,17 +65,17 @@ public class JsonController implements RestController {
|
||||
|
||||
response.status(200);
|
||||
|
||||
responseJson.addProperty("data", this.gson.toJson(requestJson));
|
||||
responseJson.addProperty("result", this.gson.toJson(requestJson));
|
||||
responseJson.addProperty("time", System.currentTimeMillis() - startProcess);
|
||||
|
||||
response.body(this.gson.toJson(responseJson));
|
||||
} catch (Exception e) {
|
||||
this.logger.error("Error on minimizeing Json " + e);
|
||||
this.logger.error("Error on minimizing Json " + e);
|
||||
Throwable cause = e.getCause();
|
||||
|
||||
response.status(400);
|
||||
|
||||
responseJson.addProperty("data", cause == null ? e.getMessage() : cause.getMessage());
|
||||
responseJson.addProperty("result", cause == null ? e.getMessage() : cause.getMessage());
|
||||
responseJson.addProperty("time", System.currentTimeMillis() - startProcess);
|
||||
|
||||
response.body(this.prettyGson.toJson(responseJson));
|
||||
|
||||
Reference in New Issue
Block a user