Fixed Minor Code Smells issues "Deprecated JsonParser" 16/128016/2
authorsharath reddy <bs.reddy@huawei.com>
Wed, 23 Mar 2022 15:52:21 +0000 (21:22 +0530)
committersharath reddy <bs.reddy@huawei.com>
Wed, 23 Mar 2022 15:59:38 +0000 (21:29 +0530)
Issue-ID: CLI-439

Signed-off-by: sharath reddy <bs.reddy@huawei.com>
Change-Id: I49fdc2fe1aa48ae78317aba94fdd7f0232334860
Signed-off-by: sharath reddy <bs.reddy@huawei.com>
framework/src/main/java/org/onap/cli/fw/output/print/OnapCommandPrint.java
grpc/grpc-server/src/main/java/org/open/infc/grpc/server/OpenInterfaceGrpcServer.java
profiles/http/src/main/java/org/onap/cli/fw/http/utils/OnapCommandHttpUtils.java
validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockRequest.java
validate/sample-mock-generator/src/main/java/org/onap/cli/http/mock/MockResponse.java

index 6850fe3..d2bc98b 100644 (file)
@@ -270,7 +270,7 @@ public class OnapCommandPrint {
                 array.add(rowO);
             }
             try {
-                return new JsonParser().parse(array.toJSONString()).toString();
+                return JsonParser.parseString(array.toJSONString()).toString();
             } catch (Exception e) { // NOSONAR
                 return array.toJSONString();
             }
index ba9920c..7b00c16 100644 (file)
@@ -277,7 +277,7 @@ public class OpenInterfaceGrpcServer {
 
         public static void setOutputAttr(Builder reply, String printOut){
             try {
-                reply.putAttrs(OnapCommandConstants.RESULTS, new JsonParser().parse(printOut).toString());
+                reply.putAttrs(OnapCommandConstants.RESULTS, JsonParser.parseString(printOut).toString());
             } catch (Exception e) { // NOSONAR
                 reply.putAttrs(OnapCommandConstants.RESULTS, printOut);
             }
index dcc3082..7780701 100644 (file)
@@ -304,10 +304,9 @@ public class OnapCommandHttpUtils {
     }
 
     public static String normalizeJson(String json) throws OnapCommandHttpInvalidRequestBody {
-        JsonParser jsonParser = new JsonParser();
         JsonElement node;
         try {
-            node = jsonParser.parse(json);
+            node = JsonParser.parseString(json);
             normalizeJson(node);
             return gson.toJson(node);
         } catch (Exception e) {  //NOSONAR
index 7b3e573..1a70be3 100644 (file)
@@ -61,10 +61,9 @@ public class MockRequest {
     public void setJson(String json) throws IOException { //NOSONAR
         if (!json.isEmpty()) {
             try {
-                JsonParser parser = new JsonParser();
-                this.json = parser.parse(json);
+                this.json = JsonParser.parseString(json);
             } catch (Exception e) {
-                this.json = new JsonParser().parse("{}");
+                this.json = JsonParser.parseString("{}");
             }
         }
 
index 7f605c3..fedfb02 100644 (file)
@@ -39,10 +39,9 @@ public class MockResponse {
     public void setJson(String json) throws IOException { //NOSONAR
         if (json != null && !json.isEmpty()) {
             try {
-                JsonParser parser = new JsonParser();
-                this.json = parser.parse(json);
+                this.json = JsonParser.parseString(json);
             } catch (Exception e) {
-                this.json = new JsonParser().parse("{}");
+                this.json = JsonParser.parseString("{}");
             }
         }
     }