public static Map < String , String > json2map ( String prefix , JsonNode json ) { logger . trace ( "json to map - prefix: {}" , prefix ) ; if ( json . isArray ( ) ) { Map < String , String > result = new HashMap <> ( ) ; for ( int i = 0 ; i < json . size ( ) ; i ++ ) { result . putAll ( json2map ( prefix + "[" + i + "]" , json . get ( i ) ) ) ; } return result ; } else if ( json . isObject ( ) ) { Map < String , String > result = new HashMap <> ( ) ; json . fields ( ) . forEachRemaining ( e -> { String newPrefix = isEmptyStr ( prefix ) ? e . getKey ( ) : prefix + "." + e . getKey ( ) ; result . putAll ( json2map ( newPrefix , e . getValue ( ) ) ) ; } ) ; return result ; } else { return newmap ( entry ( prefix , json . asText ( ) ) ) ; } }
Construct data map from inputting jackson json object