Can we make conditional mapping using JMESPath?

Say I have the displayType key that can have the values ‘text’ and ‘select’. Now I would want to map that to TEXT and SINGLESELECT accordingly. I tried the following, that results in an error:

“myType”: “&{[?displayType == ‘text’ || displayType == ‘null’].[‘TEXT’] | [?displayType == ‘select’].[‘SINGLESELECT’]}”

Hi @kjetil

Could you please confirm whether the below data is what you mentioned?

{
  "displayType": "text" // its value can be "text" or "select"
}

If it’s correct, it’s better to use a Value Mapper and a Dictionary Map such as below.

Feel free to let me know if this is not the case.

Yes, the data in displayType is as you say. I already used the dictionary map and that works, but I was interested if this could be done also using JMESPath.

Great to hear that you managed to solve it by using the dictionary map.

It seems that JMESPath is still unable to return something that is not in the entity at the moment, as it’s intended as a query language for JSON.