Having a variable as a JSON object key
Scenario:
You need to have a structure like this, where the variable is the key in the object, instead of the value. In this example, the string ”jonesa” needs to become a variable
{ "userPerms": { "jonesa": "Editor" } }
Solution:
The variable name can be enclosed in square brackets [ ] in the key field, creating a JSON structure like this:
{ "userPerms": { [$username]: "Editor" } }