ArafatKhan2198 commented on code in PR #6400:
URL: https://github.com/apache/ozone/pull/6400#discussion_r1535085467


##########
hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/nssummary/DiskUsageSubCommand.java:
##########
@@ -101,21 +99,20 @@ public Void call() throws Exception {
       return null;
     }
 
-    HashMap<String, Object> duResponse = getResponseMap(response);
+    JsonNode duResponse = JsonUtils.readTree(response);

Review Comment:
   Thanks for your suggestion, @devmadhuu  I switched to using `JsonNode` 
because it makes working with JSON data easier and more straightforward. 
`ObjectMapper` and JsonNode are both from the Jackson library, which is a 
popular choice for handling JSON, and I use them in other parts of my code too.
   
   `Type Safety` is another reason because working with HashMap<String, Object> 
requires casting values to their expected types, which can lead to 
ClassCastException if the type is incorrect. In contrast, JsonNode offers 
methods like `asText()`, `asInt()`, `asLong()`, and so on, which safely convert 
the value to the desired type or return a default value if the conversion is 
not possible. This reduces the risk of runtime errors.
   
   And also the code looks more simplified when using JsonNode especially when 
dealing with nested JSON objects or arrays.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to