Fixed not working JSON arrays (#206)
Co-authored-by: Adam Bem <adam.bem@zoho.eu> Reviewed-on: #206 Reviewed-by: Mikolaj Widla <widlam@noreply.example.com>
This commit is contained in:
@@ -1,8 +1,7 @@
|
||||
package com.r11.tools.controller;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.*;
|
||||
//import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.r11.tools.controller.internal.GlobalControllerManifest;
|
||||
import com.r11.tools.controller.internal.HandlerType;
|
||||
import com.r11.tools.controller.internal.RestController;
|
||||
@@ -11,6 +10,9 @@ import spark.Request;
|
||||
import spark.Response;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@GlobalControllerManifest(path = "/json")
|
||||
public class JsonController implements RestController {
|
||||
|
||||
@@ -32,9 +34,7 @@ public class JsonController implements RestController {
|
||||
JsonObject responseJson = new JsonObject();
|
||||
|
||||
try {
|
||||
JsonObject requestJson = this.gson.fromJson(request.body(), JsonObject.class);
|
||||
|
||||
response.status(200);
|
||||
Object requestJson = this.gson.fromJson(request.body(), Object.class);
|
||||
|
||||
responseJson.addProperty("data", this.prettyGson.toJson(requestJson));
|
||||
responseJson.addProperty("time", System.currentTimeMillis() - startProcess);
|
||||
@@ -61,7 +61,7 @@ public class JsonController implements RestController {
|
||||
JsonObject responseJson = new JsonObject();
|
||||
|
||||
try {
|
||||
JsonObject requestJson = this.prettyGson.fromJson(request.body(), JsonObject.class);
|
||||
Object requestJson = this.prettyGson.fromJson(request.body(), Object.class);
|
||||
|
||||
response.status(200);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user