@Test(dataProvider = "pathProvider") public void testToSimpleTraversrPath(Object... paths) { String humanReadablePath = JoltUtils.toSimpleTraversrPath(paths); Assert.assertEquals(new SimpleTraversal<>(humanReadablePath).get(jsonSource).get(), navigate(jsonSource, paths)); }
public static String toSimpleTraversrPath(Object[] paths) { StringBuilder pathBuilder = new StringBuilder(); for(int i=0; i<paths.length; i++) { Object path = paths[i]; if(path instanceof Integer) { pathBuilder.append("[").append(((Integer) path).intValue()).append("]"); } else if(path instanceof String) { pathBuilder.append(path.toString()); } else{ throw new UnsupportedOperationException("Only Strings and Integers are supported as path element"); } if(!(i+1 == paths.length)) { pathBuilder.append("."); } } return pathBuilder.toString(); }
JoltUtils { public static String toSimpleTraversrPath(Object[] paths) { StringBuilder pathBuilder = new StringBuilder(); for(int i=0; i<paths.length; i++) { Object path = paths[i]; if(path instanceof Integer) { pathBuilder.append("[").append(((Integer) path).intValue()).append("]"); } else if(path instanceof String) { pathBuilder.append(path.toString()); } else{ throw new UnsupportedOperationException("Only Strings and Integers are supported as path element"); } if(!(i+1 == paths.length)) { pathBuilder.append("."); } } return pathBuilder.toString(); } }
JoltUtils { public static String toSimpleTraversrPath(Object[] paths) { StringBuilder pathBuilder = new StringBuilder(); for(int i=0; i<paths.length; i++) { Object path = paths[i]; if(path instanceof Integer) { pathBuilder.append("[").append(((Integer) path).intValue()).append("]"); } else if(path instanceof String) { pathBuilder.append(path.toString()); } else{ throw new UnsupportedOperationException("Only Strings and Integers are supported as path element"); } if(!(i+1 == paths.length)) { pathBuilder.append("."); } } return pathBuilder.toString(); }  }
JoltUtils { public static String toSimpleTraversrPath(Object[] paths) { StringBuilder pathBuilder = new StringBuilder(); for(int i=0; i<paths.length; i++) { Object path = paths[i]; if(path instanceof Integer) { pathBuilder.append("[").append(((Integer) path).intValue()).append("]"); } else if(path instanceof String) { pathBuilder.append(path.toString()); } else{ throw new UnsupportedOperationException("Only Strings and Integers are supported as path element"); } if(!(i+1 == paths.length)) { pathBuilder.append("."); } } return pathBuilder.toString(); }  static void removeRecursive( Object json, String keyToRemove ); static T navigate( final Object source, final Object... paths ); static T navigateStrict( final Object source, final Object... paths ); static T navigateOrDefault( final T defaultValue, final Object source, final Object... paths ); @Deprecated static T navigateSafe(final T defaultValue, final Object source, final Object... paths); static boolean isVacantJson(final Object obj); static boolean isBlankJson(final Object obj); static List<Object[]> listKeyChains(final Object source); static List<Object[]> listKeyChains(final Object key, final Object value); static String toSimpleTraversrPath(Object[] paths); @SuppressWarnings("unchecked") static T cast(Object object); @SuppressWarnings("unchecked") static E[] cast(Object[] object); @SuppressWarnings("unchecked") static Object compactJson(Object source); @SuppressWarnings( "unchecked" ) static T store( Object source, T value, Object... paths ); @SuppressWarnings( "unchecked" ) static T remove( Object source, Object... paths ); }
JoltUtils { public static String toSimpleTraversrPath(Object[] paths) { StringBuilder pathBuilder = new StringBuilder(); for(int i=0; i<paths.length; i++) { Object path = paths[i]; if(path instanceof Integer) { pathBuilder.append("[").append(((Integer) path).intValue()).append("]"); } else if(path instanceof String) { pathBuilder.append(path.toString()); } else{ throw new UnsupportedOperationException("Only Strings and Integers are supported as path element"); } if(!(i+1 == paths.length)) { pathBuilder.append("."); } } return pathBuilder.toString(); }  static void removeRecursive( Object json, String keyToRemove ); static T navigate( final Object source, final Object... paths ); static T navigateStrict( final Object source, final Object... paths ); static T navigateOrDefault( final T defaultValue, final Object source, final Object... paths ); @Deprecated static T navigateSafe(final T defaultValue, final Object source, final Object... paths); static boolean isVacantJson(final Object obj); static boolean isBlankJson(final Object obj); static List<Object[]> listKeyChains(final Object source); static List<Object[]> listKeyChains(final Object key, final Object value); static String toSimpleTraversrPath(Object[] paths); @SuppressWarnings("unchecked") static T cast(Object object); @SuppressWarnings("unchecked") static E[] cast(Object[] object); @SuppressWarnings("unchecked") static Object compactJson(Object source); @SuppressWarnings( "unchecked" ) static T store( Object source, T value, Object... paths ); @SuppressWarnings( "unchecked" ) static T remove( Object source, Object... paths );  }