import org.onap.cli.fw.error.OnapCommandOutputPrintingFailed;
import org.onap.cli.fw.output.OnapCommandPrintDirection;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
+import com.google.gson.JsonParser;
import net.minidev.json.JSONArray;
import net.minidev.json.JSONObject;
*/
public class OnapCommandPrint {
- private static Gson gson = new GsonBuilder().serializeNulls().create();
public static final int MAX_COLUMN_LENGTH = 50;
array.add(rowO);
}
try {
- return gson.toJson(array.toJSONString()).toString();
+ return new JsonParser().parse(array.toJSONString()).toString();
} catch (Exception e) { // NOSONAR
// TODO Auto-generated catch block
return array.toJSONString();
import com.google.gson.GsonBuilder;
public class OnapCommandResultTest {
- private static Gson gson = new GsonBuilder().serializeNulls().create();
@Test
@Ignore
res.setRecords(list);
res.setScope(OnapCommandResultAttributeScope.LONG);
res.setType(OnapCommandResultType.JSON);
-
String result = res.print();
String expRes="[{\"param\":{\"id\":\"0001\",\"value\":\"result\"}}]";
- assertEquals(gson.toJson(expRes),result);
+ assertEquals(expRes,result);
}
}
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
+import com.google.gson.JsonParser;
import io.grpc.Server;
import io.grpc.ServerBuilder;
public class OpenInterfaceGrpcServer {
private static final Logger logger = LoggerFactory.getLogger(OpenInterfaceGrpcServer.class.getName());
- private static Gson gson = new GsonBuilder().serializeNulls().create();
private static final String CONF_FILE = "oclip-grpc-server.properties";
private static final String CONF_SERVER_PORT = "oclip.grpc_server_port";
reply.setSuccess(cmd.getResult().isPassed());
try {
- reply.putAttrs(OnapCommandConstants.RESULTS, gson.fromJson(printOut,String.class));
+ reply.putAttrs(OnapCommandConstants.RESULTS, new JsonParser().parse(printOut).toString());
} catch (Exception e) { // NOSONAR
reply.putAttrs(OnapCommandConstants.RESULTS, printOut);
}
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
+
import com.jayway.jsonpath.JsonPath;
import com.jayway.jsonpath.PathNotFoundException;
}
public static String normalizeJson(String json) throws OnapCommandHttpInvalidRequestBody {
+ JsonParser jsonParser = new JsonParser();
JsonElement node;
try {
- node = gson.fromJson(json,JsonElement.class);
+ node = jsonParser.parse(json);
normalizeJson(node);
return gson.toJson(node);
} catch (Exception e) { //NOSONAR
import java.net.URL;
import java.util.Map;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
+import com.google.gson.JsonParser;
import com.google.gson.JsonElement;
public class MockRequest {
private String uri;
private Map<String, String> headers;
private JsonElement json;
- private static Gson gson = new GsonBuilder().serializeNulls().create();
-
public String getMethod() {
return method;
}
public void setJson(String json) throws IOException {
if (!json.isEmpty()) {
try {
- this.json = gson.fromJson(json,JsonElement.class);
+ JsonParser parser = new JsonParser();
+ this.json = parser.parse(json);
} catch (Exception e) {
- this.json = gson.fromJson("{}",JsonElement.class);
+ this.json = new JsonParser().parse("{}");
}
}
import java.io.IOException;
-import com.google.gson.Gson;
-import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
+import com.google.gson.JsonParser;
public class MockResponse {
private int status;
private JsonElement json;
- private static Gson gson = new GsonBuilder().serializeNulls().create();
-
public int getStatus() {
return status;
}
public void setJson(String json) throws IOException {
if (json != null && !json.isEmpty()) {
try {
- this.json = gson.fromJson(json,JsonElement.class);
+ JsonParser parser = new JsonParser();
+ this.json = parser.parse(json);
} catch (Exception e) {
- this.json = gson.fromJson("{}", JsonElement.class);
+ this.json = new JsonParser().parse("{}");
}
}
}