Class JsonMapFlattener

java.lang.Object
org.springframework.vault.support.JsonMapFlattener

public abstract class JsonMapFlattener extends Object
Flattens a hierarchical Map of objects into a property Map.

Flattening is particularly useful when representing a JSON object as Properties

JsonMapFlattener flattens maps containing nested List, Map and simple values into a flat representation. The hierarchical structure is reflected in properties using dot-notation. Nested maps are considered as sub-documents.

Input:

     {"key": {"nested: 1}, "another.key": ["one", "two"] }
 

Result
  key.nested=1
  another.key[0]=one
  another.key[1]=two
 
Author:
Mark Paluch
  • Method Details

    • flatten

      public static Map<String,Object> flatten(Map<String,? extends Object> inputMap)
      Flatten a hierarchical Map into a flat Map with key names using property dot notation.
      Parameters:
      inputMap - must not be null.
      Returns:
      the resulting Map.
    • flattenToStringMap

      public static Map<String,String> flattenToStringMap(Map<String,? extends Object> inputMap)
      Flatten a hierarchical Map into a flat Map with key names using property dot notation.
      Parameters:
      inputMap - must not be null.
      Returns:
      the resulting Map.
      Since:
      2.0