Legacy Dev Forum Posts

 View Only

Sign Up

Parse json and get an array output

  • 1.  Parse json and get an array output

    Posted 06-05-2025 18:18

    sureshuppara | 2020-12-23 03:29:25 UTC | #1

    Hi, Could you please help me to get list of conversations ids into array only for "email" media types in the Response template:

    {
      "results": [
        {
          "group": {
            "queueId": "XXXXXXXXXXXXXXXXXXXX",
            "mediaType": "email"
          },
          "data": [
            {
              "metric": "oWaiting",
              "stats": {
                "count": 2
              },
              "truncated": false,
              "observations": [
                {
                  "observationDate": "2020-12-23T03:20:55.548Z",
                  "conversationId": "XXXXXXXXXXXXXXXXXXXXX",
                  "sessionId": "XXXXXXXXXXXXXXXXXXXXXXX",
                  "routingPriority": 0,
                  "participantName": "Test Customer2",
                  "direction": "inbound",
                  "addressFrom": "Test2@gmail.com",
                  "addressTo": "test@genesys.com",
                  "requestedRoutings": [
                    "Standard"
                  ]
                },
                {
                  "observationDate": "2020-12-23T03:21:03.922Z",
                  "conversationId": "XXXXXXXXXXXXXXXXXXXX",
                  "sessionId": "XXXXXXXXXXXXXX",
                  "routingPriority": 0,
                  "participantName": "Test Customer",
                  "direction": "inbound",
                  "addressFrom": "Test@gmail.com",
                  "addressTo": "Test@genesys.com",
                  "requestedRoutings": [
                    "Standard"
                  ]
                }
              ]
            }
          ]
        },
        {
          "group": {
            "queueId": "XXXXXXXXXXXXXXXXXXXXXXX",
            "mediaType": "chat"
          },
          "data": [
            {
              "metric": "oWaiting",
              "stats": {
                "count": 0
              }
            }
          ]
        },
        {
          "group": {
            "queueId": "XXXXXXXXXXXXXXXXXXXXX",
            "mediaType": "voice"
          },
          "data": [
            {
              "metric": "oWaiting",
              "stats": {
                "count": 0
              }
            }
          ]
        },
        {
          "group": {
            "queueId": "XXXXXXXXXXXXXXXXXXXXXXXXXXX",
            "mediaType": "callback"
          },
          "data": [
            {
              "metric": "oWaiting",
              "stats": {
                "count": 0
              }
            }
          ]
        },
        {
          "group": {
            "queueId": "XXXXXXXXXXXXXXXXXXXXXX",
            "mediaType": "message"
          },
          "data": [
            {
              "metric": "oWaiting",
              "stats": {
                "count": 0
              }
            }
          ]
        }
      ]
    }

    Jason_Mathison | 2020-12-23 04:08:09 UTC | #2

    Hi sureshuppara,

    I am assuming that you are trying to use this in a data action. If so, I think a JSON path like this should work, or get you in the right area: $.results[?(@.group.mediaType == "email")].data[*].observations[*].conversationId

    However, I think that you can probably modify your query to only return the email media type. That would reduce the load of your query and may simplify the resulting JSONPath.

    --Jason


    sureshuppara | 2020-12-23 19:15:10 UTC | #3

    Thank you Jason. It helped . Thanks..!!


    system | 2021-01-23 19:15:10 UTC | #4

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 9580