@Test public void testDoesNotBlowUpOnUnmodifiableArray() { List<Object> hasNan = new ArrayList<>(); hasNan.add( 1 ); hasNan.add( Double.NaN ); hasNan.add( 2 ); Map<String,Object> map = new HashMap<>(); map.put("a", "shouldBeFirst"); map.put("hasNan", Collections.unmodifiableList( hasNan ) ); try { Sortr.sortJson( map ); } catch( UnsupportedOperationException uoe ) { Assert.fail( "Sort threw a UnsupportedOperationException" ); } }
@SuppressWarnings( "unchecked" ) public static Object sortJson( Object obj ) { if ( obj instanceof Map ) { return sortMap( (Map<String, Object>) obj ); } else if ( obj instanceof List ) { return ordered( (List<Object>) obj ); } else { return obj; } }
Sortr implements Transform { @SuppressWarnings( "unchecked" ) public static Object sortJson( Object obj ) { if ( obj instanceof Map ) { return sortMap( (Map<String, Object>) obj ); } else if ( obj instanceof List ) { return ordered( (List<Object>) obj ); } else { return obj; } } }
Sortr implements Transform { @SuppressWarnings( "unchecked" ) public static Object sortJson( Object obj ) { if ( obj instanceof Map ) { return sortMap( (Map<String, Object>) obj ); } else if ( obj instanceof List ) { return ordered( (List<Object>) obj ); } else { return obj; } }  }
Sortr implements Transform { @SuppressWarnings( "unchecked" ) public static Object sortJson( Object obj ) { if ( obj instanceof Map ) { return sortMap( (Map<String, Object>) obj ); } else if ( obj instanceof List ) { return ordered( (List<Object>) obj ); } else { return obj; } }  @Override Object transform( Object input ); @SuppressWarnings( "unchecked" ) static Object sortJson( Object obj ); }
Sortr implements Transform { @SuppressWarnings( "unchecked" ) public static Object sortJson( Object obj ) { if ( obj instanceof Map ) { return sortMap( (Map<String, Object>) obj ); } else if ( obj instanceof List ) { return ordered( (List<Object>) obj ); } else { return obj; } }  @Override Object transform( Object input ); @SuppressWarnings( "unchecked" ) static Object sortJson( Object obj );  }