@Test (dataProvider = "coordinates") @SuppressWarnings("deprecation") public void navigator(Object expected, Object[] path) throws Exception { Object actual = JsonUtils.navigate(jsonSource, path); Assert.assertEquals(actual, expected); }
@SuppressWarnings("unchecked") @Deprecated public static <T> T navigate(Object source, Object... paths) throws NullPointerException, UnsupportedOperationException { Object destination = source; for (Object path : paths) { if(destination == null) throw new NullPointerException("Navigation not possible on null object"); if(destination instanceof Map) destination = ((Map) destination).get(path); else if(path instanceof Integer && destination instanceof List) destination = ((List) destination).get((Integer)path); else throw new UnsupportedOperationException("Navigation supports only Map and List source types and non-null String and Integer path types"); } return (T) destination; }
JsonUtils { @SuppressWarnings("unchecked") @Deprecated public static <T> T navigate(Object source, Object... paths) throws NullPointerException, UnsupportedOperationException { Object destination = source; for (Object path : paths) { if(destination == null) throw new NullPointerException("Navigation not possible on null object"); if(destination instanceof Map) destination = ((Map) destination).get(path); else if(path instanceof Integer && destination instanceof List) destination = ((List) destination).get((Integer)path); else throw new UnsupportedOperationException("Navigation supports only Map and List source types and non-null String and Integer path types"); } return (T) destination; } }
JsonUtils { @SuppressWarnings("unchecked") @Deprecated public static <T> T navigate(Object source, Object... paths) throws NullPointerException, UnsupportedOperationException { Object destination = source; for (Object path : paths) { if(destination == null) throw new NullPointerException("Navigation not possible on null object"); if(destination instanceof Map) destination = ((Map) destination).get(path); else if(path instanceof Integer && destination instanceof List) destination = ((List) destination).get((Integer)path); else throw new UnsupportedOperationException("Navigation supports only Map and List source types and non-null String and Integer path types"); } return (T) destination; }  }
JsonUtils { @SuppressWarnings("unchecked") @Deprecated public static <T> T navigate(Object source, Object... paths) throws NullPointerException, UnsupportedOperationException { Object destination = source; for (Object path : paths) { if(destination == null) throw new NullPointerException("Navigation not possible on null object"); if(destination instanceof Map) destination = ((Map) destination).get(path); else if(path instanceof Integer && destination instanceof List) destination = ((List) destination).get((Integer)path); else throw new UnsupportedOperationException("Navigation supports only Map and List source types and non-null String and Integer path types"); } return (T) destination; }  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 { @SuppressWarnings("unchecked") @Deprecated public static <T> T navigate(Object source, Object... paths) throws NullPointerException, UnsupportedOperationException { Object destination = source; for (Object path : paths) { if(destination == null) throw new NullPointerException("Navigation not possible on null object"); if(destination instanceof Map) destination = ((Map) destination).get(path); else if(path instanceof Integer && destination instanceof List) destination = ((List) destination).get((Integer)path); else throw new UnsupportedOperationException("Navigation supports only Map and List source types and non-null String and Integer path types"); } return (T) destination; }  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);  }