@Test(dataProvider = "removeRecursiveCases") @SuppressWarnings("deprecation") public void testRemoveRecursive(Object json, String key, Object expected) throws IOException { JsonUtils.removeRecursive( json, key ); Diffy.Result result = diffy.diff( expected, json ); if (!result.isEmpty()) { Assert.fail( "Failed.\nhere is a diff:\nexpected: " + JsonUtils.toJsonString( result.expected ) + "\n actual: " + JsonUtils.toJsonString( result.actual ) ); } }
@Deprecated public static void removeRecursive( Object json, String keyToRemove ) { if ( ( json == null ) || ( keyToRemove == null ) ) { return; } if ( json instanceof Map ) { @SuppressWarnings("unchecked") Map<String, Object> jsonMap = (Map<String, Object>) json; if ( jsonMap.containsKey( keyToRemove ) ) { jsonMap.remove( keyToRemove ); } for ( Object value : jsonMap.values() ) { removeRecursive( value, keyToRemove ); } } if ( json instanceof List ) { for ( Object value : (List) json ) { removeRecursive( value, keyToRemove ); } } }
JsonUtils { @Deprecated public static void removeRecursive( Object json, String keyToRemove ) { if ( ( json == null ) || ( keyToRemove == null ) ) { return; } if ( json instanceof Map ) { @SuppressWarnings("unchecked") Map<String, Object> jsonMap = (Map<String, Object>) json; if ( jsonMap.containsKey( keyToRemove ) ) { jsonMap.remove( keyToRemove ); } for ( Object value : jsonMap.values() ) { removeRecursive( value, keyToRemove ); } } if ( json instanceof List ) { for ( Object value : (List) json ) { removeRecursive( value, keyToRemove ); } } } }
JsonUtils { @Deprecated public static void removeRecursive( Object json, String keyToRemove ) { if ( ( json == null ) || ( keyToRemove == null ) ) { return; } if ( json instanceof Map ) { @SuppressWarnings("unchecked") Map<String, Object> jsonMap = (Map<String, Object>) json; if ( jsonMap.containsKey( keyToRemove ) ) { jsonMap.remove( keyToRemove ); } for ( Object value : jsonMap.values() ) { removeRecursive( value, keyToRemove ); } } if ( json instanceof List ) { for ( Object value : (List) json ) { removeRecursive( value, keyToRemove ); } } }  }
JsonUtils { @Deprecated public static void removeRecursive( Object json, String keyToRemove ) { if ( ( json == null ) || ( keyToRemove == null ) ) { return; } if ( json instanceof Map ) { @SuppressWarnings("unchecked") Map<String, Object> jsonMap = (Map<String, Object>) json; if ( jsonMap.containsKey( keyToRemove ) ) { jsonMap.remove( keyToRemove ); } for ( Object value : jsonMap.values() ) { removeRecursive( value, keyToRemove ); } } if ( json instanceof List ) { for ( Object value : (List) json ) { removeRecursive( value, keyToRemove ); } } }  static JsonUtil customJsonUtil( ObjectMapper mapper ); @Deprecated static void removeRecursive( Object json, String keyToRemove ); static Map<String, Object> javason( String javason ); static JsonUtil getDefaultJsonUtil(); static Object jsonToObject( String json ); static Object jsonToObject( String json, String charset ); static Object jsonToObject( InputStream in ); static Map<String, Object> jsonToMap( String json ); static Map<String, Object> jsonToMap( String json, String charset ); static Map<String, Object> jsonToMap( InputStream in ); static List<Object> jsonToList( String json ); static List<Object> jsonToList( String json, String charset ); static List<Object> jsonToList( InputStream in ); static Object filepathToObject( String filePath ); static Map<String, Object> filepathToMap( String filePath ); static List<Object> filepathToList( String filePath ); static Object classpathToObject( String classPath ); static Map<String, Object> classpathToMap( String classPath ); static List<Object> classpathToList( String classPath ); static T classpathToType( String classPath, TypeReference<T> typeRef ); static T classpathToType( String classPath, Class<T> aClass ); static T stringToType( String json, TypeReference<T> typeRef ); static T stringToType( String json, Class<T> aClass ); static T fileToType( String filePath, TypeReference<T> typeRef ); static T fileToType( String filePath, Class<T> aClass ); static T streamToType( InputStream in, TypeReference<T> typeRef ); static T streamToType( InputStream in, Class<T> aClass ); @Deprecated static T jsonTo( String json, TypeReference<T> typeRef ); @Deprecated static T jsonTo( InputStream in, TypeReference<T> typeRef ); static String toJsonString( Object obj ); static String toPrettyJsonString( Object obj ); static Object cloneJson( Object obj ); @SuppressWarnings("unchecked") @Deprecated static T navigate(Object source, Object... paths); }
JsonUtils { @Deprecated public static void removeRecursive( Object json, String keyToRemove ) { if ( ( json == null ) || ( keyToRemove == null ) ) { return; } if ( json instanceof Map ) { @SuppressWarnings("unchecked") Map<String, Object> jsonMap = (Map<String, Object>) json; if ( jsonMap.containsKey( keyToRemove ) ) { jsonMap.remove( keyToRemove ); } for ( Object value : jsonMap.values() ) { removeRecursive( value, keyToRemove ); } } if ( json instanceof List ) { for ( Object value : (List) json ) { removeRecursive( value, keyToRemove ); } } }  static JsonUtil customJsonUtil( ObjectMapper mapper ); @Deprecated static void removeRecursive( Object json, String keyToRemove ); static Map<String, Object> javason( String javason ); static JsonUtil getDefaultJsonUtil(); static Object jsonToObject( String json ); static Object jsonToObject( String json, String charset ); static Object jsonToObject( InputStream in ); static Map<String, Object> jsonToMap( String json ); static Map<String, Object> jsonToMap( String json, String charset ); static Map<String, Object> jsonToMap( InputStream in ); static List<Object> jsonToList( String json ); static List<Object> jsonToList( String json, String charset ); static List<Object> jsonToList( InputStream in ); static Object filepathToObject( String filePath ); static Map<String, Object> filepathToMap( String filePath ); static List<Object> filepathToList( String filePath ); static Object classpathToObject( String classPath ); static Map<String, Object> classpathToMap( String classPath ); static List<Object> classpathToList( String classPath ); static T classpathToType( String classPath, TypeReference<T> typeRef ); static T classpathToType( String classPath, Class<T> aClass ); static T stringToType( String json, TypeReference<T> typeRef ); static T stringToType( String json, Class<T> aClass ); static T fileToType( String filePath, TypeReference<T> typeRef ); static T fileToType( String filePath, Class<T> aClass ); static T streamToType( InputStream in, TypeReference<T> typeRef ); static T streamToType( InputStream in, Class<T> aClass ); @Deprecated static T jsonTo( String json, TypeReference<T> typeRef ); @Deprecated static T jsonTo( InputStream in, TypeReference<T> typeRef ); static String toJsonString( Object obj ); static String toPrettyJsonString( Object obj ); static Object cloneJson( Object obj ); @SuppressWarnings("unchecked") @Deprecated static T navigate(Object source, Object... paths);  }