Is there a way to *dynamically* add a new element to a dictionary?

I'd like to at run time add new name value pair to a dictionary. Is this possible?

Thanks.

OriginalPostID-239395

  Discussion posts and replies are publicly visible

Parents Reply
  • Why is an update no option? The new version includes to old functions as well.

    This is a quick solution. I am pretty sure there is a better one.

    a!localVariables(
      local!values: {{ id:1, name:"alpha" },{ id:2, name:"bravo" },{ id:3, name:"charlie" }},
      reduce(
        updatecdt(_,_),
        cast(type!Dictionary, {}),
        a!forEach(
          items: local!values,
          expression: a!fromJson(
            substitute(
              a!toJson({tzqYx62_01_: fv!item.name}),
              "tzqYx62_01_",
              fv!item.id
            )
          )
        )
      )
    )

Children