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
  • I guess it takes a little trickery to get the plaintext key name to be the key in a new dictionary, but if we (for instance) use JSON as an intermediary step, that'll pretty much do it for us...

    a!localVariables(
      local!originalDictionary: {
        'a': true,
        'b': true,
        'c': false,
        'd': false
      },
      
      local!keys: a!keys(local!originalDictionary),
      
      a!forEach(
        local!keys,
        
        /* note: double quotes have to be handled carefully here */
        a!fromJson(
          "{""" & fv!item & """:" & property(local!originalDictionary, fv!item) & "}"
        )
      )
    )

Children