rdblue commented on a change in pull request #4037:
URL: https://github.com/apache/iceberg/pull/4037#discussion_r810547327



##########
File path: core/src/main/java/org/apache/iceberg/util/JsonUtil.java
##########
@@ -129,6 +130,42 @@ public static String getStringOrNull(String property, 
JsonNode node) {
     return builder.build();
   }
 
+  public static Map<String, String> getStringMapOrNull(String property, 
JsonNode node) {
+    if (!node.has(property)) {
+      return null;
+    }
+
+    JsonNode pNode = node.get(property);
+    if (pNode == null || pNode.isNull()) {
+      return null;
+    }
+
+    Preconditions.checkArgument(pNode.isObject(),
+        "Cannot parse %s from non-object value: %s", property, pNode);
+    return buildStringMapFromJsonNodeObject(pNode);
+  }
+
+  private static Map<String, String> buildStringMapFromJsonNodeObject(JsonNode 
pNode) {
+    ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();
+    Iterator<String> fields = pNode.fieldNames();
+    while (fields.hasNext()) {
+      String field = fields.next();
+      builder.put(field, getString(field, pNode));
+    }
+    return builder.build();
+  }
+
+  public static String[] getStringArray(JsonNode node) {
+    Preconditions.checkArgument(node != null && !node.isNull() && 
node.isArray(),
+        "Cannot parse string array from non-array value: %s", node);

Review comment:
       I think "value" can be omitted.




-- 
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