Class JsonConfigFlattener

java.lang.Object
io.quarkiverse.amazon.common.runtime.JsonConfigFlattener

public final class JsonConfigFlattener extends Object
Utility class for detecting and flattening JSON values from AWS config sources.

This class provides methods to:

  • Detect if a value is JSON (starts with '{' or '[')
  • Flatten JSON objects and arrays into configuration keys with dot notation
  • Gracefully handle invalid JSON by returning the raw value

Used by both SSM and Secrets Manager ConfigSources to provide consistent JSON parsing behavior.

  • Method Details

    • isJsonValue

      public static boolean isJsonValue(String value)
      Checks if a value looks like JSON (starts with '{' or '[').
      Parameters:
      value - the value to check
      Returns:
      true if the trimmed value starts with '{' or '[', false otherwise
    • expandValue

      public static Map<String,String> expandValue(String prefix, String value)
      Expands a parameter/secret value into zero or more configuration keys.

      If the value is JSON (object or array), it is flattened with the prefix. If the value is properties-like (contains '='), each entry is prefixed. Otherwise, a single key with the prefix and the raw value is returned. If flattening fails (invalid JSON), the raw value is returned.

      Parameters:
      prefix - the prefix to apply to all keys (e.g., the parameter/secret name or mapped property)
      value - the value to expand
      Returns:
      a map of configuration keys to values