cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
791
Views
3
Helpful
7
Replies

How to get a value from a JSON array in UCCX?

tomc101010
Beginner
Beginner

Hello,

 

I need your help regarding obtaining some values from a JSON array in UCCX?

 

Here is a JSON file example:

{

  "took": 252,

  "timed_out": false,

  "hits": {

    "total": {

      "value": 1,

      "relation": "eq"

    },

    "hits": [

      {

        "_source": {

          "customerAttributes": [

            {

              "attributeId": 37,

              "value": "0.000"

            },

            {

              "attributeId": 6,

              "value": "20"

            }

          ],

          "customerInteractions": []

        }

      }

    ]

  }

}

 

I need to obtain the “value” for the "attributeId": 6.

The following JSON paths returns me the correct result in http://jsonpath.com/

 

$..customerAttributes[?(@.attributeId==6)].value

$.hits.hits[0]._source.customerAttributes[?(@.attributeId==6)].value

 

In the UCCX script I get the following message:

tomc101010_0-1679311799800.png

 

I know that UCCX uses the jayway implementation of JSONPath (from the previous post: @Anthony Holloway

 https://community.cisco.com/t5/contact-center/get-the-length-of-a-json-array-in-ccx/m-p/3907604/highlight/true#M112496), however link for the test is not available.

 

I think the error is inside the filter “[?(@.attributeId==6)]”, since for the JSON path – “$.hits.hits[0]._source.customerAttributes[1].value”, the UCCX returns me the value "20".

 

Any idea?

Thanks in advance.

Best regards,

Tom C

1 Accepted Solution

Accepted Solutions