output["key"] = "value"
output["key"] = value
can produce nesting, if value is one of the types that supports that. Some built-ins, like collections, do this automagically. Others do it via declaration.
I'mo go take a swing at coding this up. Then we'll see what we think when we hear what we say.