Being able to use a value to set the key

When using a Value setter it’s possible to use a variable as a key, for instance: &{PropertyName}. Works great, unless you have nested data, it does not work for other instances like List: Extend with supplied data.
For example, this will not work:

{
  "&{PropertyName}": "&{Value}"
}

How do you set the keyname using a variable? Or is there another approach?

Hi @steven

Unfortunately, it was impossible to set a key name using variables on instances like List: Extend with supplied data. As you already know, it can be done by a value setter.

Currently, I’m checking with the team, I’ll update my answer if we found another approach.

Hi @steven, to make it clear, could you please provide us with a context of your issues?
Maybe you can tell us with some kind of input, and output expected.

This is the example input:

{
  "CustomField": [
    {
      "Value": "20",
      "PropertyName": "Something"
    },
    {
      "Value": "50",
      "PropertyName": "Else"
    }
  ]
}

I want to output:

{
  "CustomField": [
    {
      "Something": "20"
    },
    {
      "Else": "50"
    }
  ]
}

I currently fixed it with a work around using node transformers, where the pattern doesn’t work :thinking:

1 Like

Hi Steven,

Please try to use this example.
You can import this into your environment.
Let me know if it doesn’t work.

forum-787-reformat-data_transformer.ndjson (938 Bytes)

Thanks for your example, I’ve made it even smaller/easier. The big note for me is the entity transformernode, transform nodes does something completely different from a Data, transform data using mappers and conditionsNode Transformer, the pattern does absolutely nothing for a Node Transformer.

Here is my setup now:

Yes, because both have different functionality.
I am glad that you can manage it.
We try to make another example to avoid a value-setter, since you asked for another approach.