@Test public void checkIfNoFieldExistsInJsonNode() throws IOException { JsonNode originalNode = mapper.readTree("{\"tenantDetails\":{\"tenantId\":\"pb.amritsar\"}," + "\"name\":{\"firstName\":\"Customer Name\"}}"); List<String> fields = Arrays.asList("asd"); assertEquals(true, JSONUtils.checkIfNoFieldExistsInJsonNode(originalNode, fields)); }
static boolean checkIfNoFieldExistsInJsonNode(JsonNode jsonNode, List<String> fields) { for(String field : fields) { if(! String.valueOf(jsonNode.findPath(field)).isEmpty()) return false; } return true; }
JSONUtils { static boolean checkIfNoFieldExistsInJsonNode(JsonNode jsonNode, List<String> fields) { for(String field : fields) { if(! String.valueOf(jsonNode.findPath(field)).isEmpty()) return false; } return true; } }
JSONUtils { static boolean checkIfNoFieldExistsInJsonNode(JsonNode jsonNode, List<String> fields) { for(String field : fields) { if(! String.valueOf(jsonNode.findPath(field)).isEmpty()) return false; } return true; }  }
JSONUtils { static boolean checkIfNoFieldExistsInJsonNode(JsonNode jsonNode, List<String> fields) { for(String field : fields) { if(! String.valueOf(jsonNode.findPath(field)).isEmpty()) return false; } return true; }  static JsonNode merge(JsonNode newNode, JsonNode originalNode); static JsonNode filterJsonNodeWithFields(JsonNode jsonNode, List<String> filterFields); static JsonNode filterJsonNodeWithPaths2(JsonNode jsonNode, List<String> filterPaths); static JsonNode filterJsonNodeForPath(JsonNode jsonNode, String filterPath); static ArrayNode filterJsonNodeWithPaths(JsonNode jsonNode, List<String> filterPaths); static JsonNode mergeNodesForGivenPaths(JsonNode newNode, JsonNode originalNode, List<String> filterPaths); }
JSONUtils { static boolean checkIfNoFieldExistsInJsonNode(JsonNode jsonNode, List<String> fields) { for(String field : fields) { if(! String.valueOf(jsonNode.findPath(field)).isEmpty()) return false; } return true; }  static JsonNode merge(JsonNode newNode, JsonNode originalNode); static JsonNode filterJsonNodeWithFields(JsonNode jsonNode, List<String> filterFields); static JsonNode filterJsonNodeWithPaths2(JsonNode jsonNode, List<String> filterPaths); static JsonNode filterJsonNodeForPath(JsonNode jsonNode, String filterPath); static ArrayNode filterJsonNodeWithPaths(JsonNode jsonNode, List<String> filterPaths); static JsonNode mergeNodesForGivenPaths(JsonNode newNode, JsonNode originalNode, List<String> filterPaths);  }