cancel
Showing results for 
Search instead for 
Did you mean: 

How to read the value from an array using expression builder and return true or false

snowamigo
New Contributor

My initial JSON looked like below

    "customFields": {
    "textCustomFields": [
      {
        "fieldId": "10546710413",
        "name": "templateUsageRestriction",
        "show": "false",
        "required": "false",
        "value": "allOptions"
      },
      {
        "fieldId": "10546710414",
        "name": "_source",
        "show": "true",
        "required": "false",
        "value": "ERM"
      },
      {
        "fieldId": "10546710415",
        "name": "_destination",
        "show": "true",
        "required": "false",
        "value": "xxx,yyy"
      },
      {
        "fieldId": "10546710416",
        "name": "_bu",
        "show": "true",
        "required": "false",
        "value": "ABC"
      },
      {
        "fieldId": "10546710417",
        "name": "_uid",
        "show": "true",
        "required": "false",
        "value": "pqr"
      },
      {
        "fieldId": "10546710418",
        "name": "_accountnumber",
        "show": "true",
        "required": "false",
        "value": "xyz"
      }
    ],
    "listCustomFields": []
  }

So I used below expression to map name => value.
Screen Shot 2021-03-06 at 11.43.04 AM

Now I am trying to read the "_source’ element value, Ideally i want to do something like $.dsConfigAttributes[‘_source’] == ‘ERM’ return true else false to a target path
and
$.dsConfigAttributes[‘_source’] contains "ERM’ return to true else false to a target path

Screen Shot 2021-03-06 at 11.36.55 AM

Any help is appreciated.

1 ACCEPTED SOLUTION

bojanvelevski
Valued Contributor

Hello @snowamigo,

If you use this expression below, you will get true/false on the target path, respectively where the value of name is ‘_source’ and value of ‘value’ is ‘ERM’.

.map(x=> x.name == ‘_source’ && x.value == ‘ERM’)

If that is what you were aiming at. If not, please send more details on the output.

Best regards,

Bojan Velevski

View solution in original post

1 REPLY 1

bojanvelevski
Valued Contributor

Hello @snowamigo,

If you use this expression below, you will get true/false on the target path, respectively where the value of name is ‘_source’ and value of ‘value’ is ‘ERM’.

.map(x=> x.name == ‘_source’ && x.value == ‘ERM’)

If that is what you were aiming at. If not, please send more details on the output.

Best regards,

Bojan Velevski