def replace_parameters_with_jsonpath()

in src/stepfunctions/template/utils.py [0:0]


def replace_parameters_with_jsonpath(step, params):

    def search_and_replace(src_params, dest_params, key):
        """Search and replace the dict entry in-place."""
        original_key = key[:-2] # Remove .$ in the end
        del src_params[original_key]
        src_params[key] = dest_params[key]

    def replace_values(src_params, dest_params):
        if isinstance(dest_params, dict):
            for key in dest_params.keys():
                if key.endswith('$'):
                    search_and_replace(src_params, dest_params, key)
                else:
                    replace_values(src_params[key], dest_params[key])
    
    task_parameters = step.parameters.copy()
    replace_values(task_parameters, params)
    
    return task_parameters