Edit: on closer look, we need more info. Your title says you want to add a new entry to a map. But your example says you want to set the value of a map entry. Would you clarify this
You need to post at least the existing map and the new entry for us to know what the issue might be. The error could be more verbose too, it might give you at least a line where the error comes up.
$json.nestedMap["action"] looks weird to me. how about $json.nestedMap.action?
Just a quick reminder (for me as well) from the docs:
In Go templates, you canβt access array, slice, or map elements directly the same way you would in Go. For example, $.Site.Data.authors[.Params.authorkey] isnβt supported syntax.
Instead, you have to use index, a function that handles the lookup for you.