Cast/convert dictionary to array of variants

{
    'a': true,
    'b': true,
    'c': false,
    'd': false
}

The code above should dynamically be converted to 

{
  { 'a': true },
  { 'b': true },
  { 'c': false },
  { 'd': false }
}

is that possible? Thanks in advance

  Discussion posts and replies are publicly visible

Parents Reply
  • +1
    Certified Lead Developer
    in reply to Mike Schmitt

    Oh, I just remembered there's a cleaner way to do this using a!update() (which can inject a new property into an existing dictionary or map), so no need to manually construct a JSON string to back-convert.  See below:

    a!localVariables(
      local!originalDictionary: {
        'a': true,
        'b': true,
        'c': false,
        'd': false
      },
      
      local!keys: a!keys(local!originalDictionary),
      
      a!forEach(
        local!keys,
        
        a!update(
          data: a!map(),
          index: fv!item,
          value: property(local!originalDictionary, fv!item)
        )
      )
    )

Children