change subvariable in FreeMarker

freemarker

Solution

I figured out a simple way to do it:

<#assign hash = hash + {"state":"MI"}>

Problem

Is there a way to change a subvariable within a hash or a container in a FreeMarker template? For example, suppose I had: ``` {"name":"Bob", "city":"Detroit", "state":"OH"} ``` and I want to change the state to "MI". How would I go about doing that? I know about the assign tag, but the documentation says "Note that only top-level variables can be created/replaced". I am unsure as to whether this means subvariables can't be replaced with the assign tag, or subvariables can't be replaced by any means.

Original source