构建JSON Map文件

时间:2019-04-29 10:03:09

标签: json sas

我有以下自动创建的地图:

{
  "DATASETS": [
{
  "DSNAME": "stats_specific_responses",
  "TABLEPATH": "/root/stats_specific_responses",
  "VARIABLES": [
    {
      "NAME": "ordinal_root",
      "TYPE": "ORDINAL",
      "PATH": "/root"
    },
    {
      "NAME": "ordinal_stats_specific_responses",
      "TYPE": "ORDINAL",
      "PATH": "/root/stats_specific_responses"
    },
    {
      "NAME": "successful",
      "TYPE": "NUMERIC",
      "PATH": "/root/stats_specific_responses/successful"
    },
    {
      "NAME": "message",
      "TYPE": "NUMERIC",
      "PATH": "/root/stats_specific_responses/message"
    },
    {
      "NAME": "start_time_in_usecs",
      "TYPE": "NUMERIC",
      "PATH": "/root/stats_specific_responses/start_time_in_usecs"
    },
    {
      "NAME": "interval_in_secs",
      "TYPE": "NUMERIC",
      "PATH": "/root/stats_specific_responses/interval_in_secs"
    },
    {
      "NAME": "metric",
      "TYPE": "CHARACTER",
      "PATH": "/root/stats_specific_responses/metric",
      "CURRENT_LENGTH": 22
    }
  ]
},
{
  "DSNAME": "stats_specific_response_values",
  "TABLEPATH": "/root/stats_specific_responses/values",
  "VARIABLES": [
    {
      "NAME": "ordinal_stats_specific_responses",
      "TYPE": "ORDINAL",
      "PATH": "/root/stats_specific_responses"
    },
    {
      "NAME": "ordinal_values",
      "TYPE": "ORDINAL",
      "PATH": "/root/stats_specific_responses/values"
    },
    {
      "NAME": "values1",
      "TYPE": "NUMERIC",
      "PATH": "/root/stats_specific_responses/values/values1"
    },
    {
      "NAME": "values2",
      "TYPE": "NUMERIC",
      "PATH": "/root/stats_specific_responses/values/values2"
    },

...

    {
      "NAME": "values25",
      "TYPE": "NUMERIC",
      "PATH": "/root/stats_specific_responses/values/values25"
    }
  ]
}
  ]
}

我正在尝试仅为度量标准名称和每个值创建一个映射,所以我尝试了:

{
  "DATASETS": [
{
  "DSNAME": "stats_specific_responses",
  "TABLEPATH": "/root/stats_specific_responses",
  "VARIABLES": [
    {
      "NAME": "metric",
      "TYPE": "CHARACTER",
      "OPTIONS": ["RETAIN"],
      "PATH": "/root/stats_specific_responses/metric",
      "CURRENT_LENGTH": 22
    }
  ]
},
{
  "DSNAME": "stats_specific_response_values",
  "TABLEPATH": "/root/stats_specific_responses/values",
  "VARIABLES": [
    {
      "NAME": "ordinal_values",
      "TYPE": "ORDINAL",
      "PATH": "/root/stats_specific_responses/values"
    }
  ]
}
  ]
}

但是这似乎只返回两个数据集stats_specific_response_values和stats_specific_responses,但是似乎返回值1和2而不是所有25个值的列表?

我希望生成一个像这样的数据集:

metric               value
storage.usage_bytes 13341141567534
storage.usage_bytes 13362922439282
storage.usage_bytes 13378102773863
storage.usage_bytes 13355459775222 
...
storage.capacity_bytes 41903034633344
storage.capacity_bytes 41903034633344
storage.capacity_bytes 41903034633344

这实际上可能吗?您可以为值1-25指定通配符,并组合两个DSNAME吗?

再次感谢您的SAS菜鸟

编辑:

我也尝试过:

{
  "DATASETS": [
    {
      "DSNAME": "BOB",
      "TABLEPATH": "/root/stats_specific_responses",
      "VARIABLES": [
        {
          "NAME": "metric",
          "TYPE": "CHARACTER",
          "OPTIONS": ["RETAIN"],
          "PATH": "/root/stats_specific_responses/metric",
          "CURRENT_LENGTH": 22
        },
        {
          "NAME": "values1",
          "TYPE": "NUMERIC",
          "PATH": "/root/stats_specific_responses/values/values1"
        },
        {
          "NAME": "values2",
          "TYPE": "NUMERIC",
          "PATH": "/root/stats_specific_responses/values/values2"
        }
      ]
    }
  ]
}

但这会导致:

metric  values1 values2
storage.usage_bytes 1.3341142E13    1.3362922E13
storage.capacity_bytes  4.1903035E13    4.1903035E13

但是值不是全部存储在同一列中,是否需要在映射中指定每个值1-25?

这里是完整的原始json:sample

0 个答案:

没有答案