2 Replies Latest reply on Sep 25, 2016 11:17 PM by Andy Gunther

    Need help parsing JSON

    Andy Gunther

      I'm fairly new to writing in javaScript, and am in need of some assistance with an example I am trying to get working.  I have a WDC that I'm working on that hits a third party service, and pulls down JSON representing the data I need to get into Tableau.  Here is the JSON string I get back:

       

      {

          "results": [

          {

              "group": {

                  "mediaType": "voice",

                  "queueId": "5aa5748e-bee8-4b48-bcd1-bfb3b9f6890f"

              },

              "data": [

              {

                  "interval": "2016-09-16T00:00:00.000Z/2016-09-23T23:59:59.999Z",

                  "metrics": [

                  {

                      "metric": "tTalk",

                      "stats": {

                          "max": 300999,

                          "count": 4,

                          "sum": 451230

                      }

                  },

                  {

                      "metric": "tAnswered",

                      "stats": {

                          "max": 213683,

                          "count": 4,

                          "sum": 261119

                      }

                  },

                  {

                      "metric": "nOffered",

                      "stats": {

                          "count": 13

                      }

                  }

                  ]

              }

              ]

          }

          ]

      }

       

      Ultimately, I need to get the tTalk sum, the tAnswered count, and the nOffered count values into the table that is populated in the getData function.  But, I'm unable to figure out just how I would iterate through the object to get to these values.  Can anyone offer some assistance?

       

      Thanks!