Analytics result model different according to queries

Not applicable

Hi all,

I have a problem with analytics.

When i use for example the following query for retrieve analytics according to a specified app :

https://api.enterprise.apigee.com/v1/organizations/amadeus-developers/environments/prod/stats/apps?s... eq '{myAppId}')&sortby=sum(message_count)&sortby=sum(is_error)&sortby=avg(total_response_time)

Apigee returns me a Json file which looks like :

{
  "environments" : [ {
    "dimensions" : [ {
      "metrics" : [ {
        "name" : "sum(message_count)",
        "values" : [ "51.0" ]
      }, {
        "name" : "avg(total_response_time)",
        "values" : [ "2262.8039215686276" ]
      }, {
        "name" : "sum(is_error)",
        "values" : [ "9.0" ]
      }, {
        "name" : "global-avg-total_response_time",
        "values" : [ "2262.8039215686276" ]
      } ],
      "name" : "{myAppId}"
    } ],
    "name" : "prod"
  } ],
  .........
}

But when i add the timeUnit query parameter, apigee returns me that (it's a part of the result) :

{
  "environments" : [ {
    "dimensions" : [ {
      "metrics" : [ {
        "name" : "sum(message_count)",
        "values" : [ {
          "timestamp" : 1485796080000,
          "value" : "1.0"
        }, {
          "timestamp" : 1485796260000,
          "value" : "1.0"
        }, {
          "timestamp" : 1485796320000,
          "value" : "1.0"
        }
.........

The problem refers to "values" form included in metrics. In the first case, values is an array of String, in the second it's a list of Object (with 2 variables : timestamp and value)

How can i make my model to handle both case ?

Thanks

0 0 91
0 REPLIES 0