public static void squashNulls( Object input ) {
        if ( input instanceof List ) {
            List inputList = (List) input;
            inputList.removeIf( java.util.Objects::isNull );
        }
        else if ( input instanceof Map ) {
            Map<String,Object> inputMap = (Map<String,Object>) input;

            List<String> keysToNuke = new ArrayList<>();
            for (Map.Entry<String,Object> entry : inputMap.entrySet()) {
                if ( entry.getValue() == null ) {
                    keysToNuke.add( entry.getKey() );
                }
            }

            inputMap.keySet().removeAll( keysToNuke );
        }
    }
public static void squashNulls ( Object input ) { if ( input instanceof List ) { List inputList = ( List ) input ; inputList . removeIf ( java . util . Objects :: isNull ) ; } else if ( input instanceof Map ) { Map < String , Object > inputMap = ( Map < String , Object > ) input ; List < String > keysToNuke = new ArrayList < > ( ) ; for ( Map . Entry < String , Object > entry : inputMap . entrySet ( ) ) { if ( entry . getValue ( ) == null ) { keysToNuke . add ( entry . getKey ( ) ) ; } } inputMap . keySet ( ) . removeAll ( keysToNuke ) ; } }
Squashes nulls in a list or map.

Modifies the data.