public static Map < String , String > serialize ( Map < String , Object > map , String prefix ) { if ( map == null || map . isEmpty ( ) ) { return Collections . emptyMap ( ) ; } Map < String , String > flattened = flatten ( map , new HashMap < String , String > ( ) , new ArrayList < String > ( ) ) ; Map < String , String > result = new HashMap <> ( ) ; for ( Map . Entry < String , String > entry : flattened . entrySet ( ) ) { result . put ( prefix + "." + entry . getKey ( ) , entry . getValue ( ) ) ; } return result ; }
Flatten a Map of String Object into a Map of String String where keys are . separated and prepends a key .