簡體   English   中英

使用邏輯應用程序將 JSON Object 轉換為平面結構

[英]Converting JSON Object to Flat Structure using Logic Apps

所以我一直在使用這個邏輯應用程序模板來點擊谷歌分析 API 並且響應是這種格式

{
  "reports": [
    {
      "columnHeader": {
        "dimensions": [
          "ga:date",
          "ga:campaign",
          "ga:country",
          "ga:browser",
          "ga:deviceCategory",
          "ga:sourceMedium",
          "ga:socialNetwork",
          "ga:region"
        ],
        "metricHeader": {
          "metricHeaderEntries": [
            {
              "name": "ga:users",
              "type": "INTEGER"
            },
            {
              "name": "ga:sessions",
              "type": "INTEGER"
            },
            {
              "name": "ga:newUsers",
              "type": "INTEGER"
            },
            {
              "name": "ga:bounces",
              "type": "INTEGER"
            },
            {
              "name": "ga:pageviews",
              "type": "INTEGER"
            },
            {
              "name": "ga:sessionDuration",
              "type": "TIME"
            },
            {
              "name": "ga:hits",
              "type": "INTEGER"
            },
            {
              "name": "ga:goalCompletionsAll",
              "type": "INTEGER"
            },
            {
              "name": "ga:goalConversionRateAll",
              "type": "PERCENT"
            }
          ]
        }
      },
      "data": {
        "rows": [
          {
            "dimensions": [
              "20200312",
              "(not set)",
              "India",
              "Chrome",
              "desktop",
              "(direct) / (none)",
              "(not set)",
              "Tamil Nadu"
            ],
            "metrics": [
              {
                "values": [
                  "4",
                  "4",
                  "4",
                  "0",
                  "111",
                  "5100.0",
                  "111",
                  "0",
                  "0.0"
                ]
              }
            ]
          },
          {
            "dimensions": [
              "20200316",
              "(not set)",
              "India",
              "Chrome",
              "desktop",
              "(direct) / (none)",
              "(not set)",
              "Tamil Nadu"
            ],
            "metrics": [
              {
                "values": [
                  "1",
                  "1",
                  "0",
                  "0",
                  "6",
                  "266.0",
                  "6",
                  "0",
                  "0.0"
                ]
              }
            ]
          },
          {
            "dimensions": [
              "20200318",
              "(not set)",
              "India",
              "Chrome",
              "desktop",
              "(direct) / (none)",
              "(not set)",
              "Tamil Nadu"
            ],
            "metrics": [
              {
                "values": [
                  "1",
                  "2",
                  "0",
                  "0",
                  "20",
                  "135.0",
                  "20",
                  "0",
                  "0.0"
                ]
              }
            ]
          }
        ],
        "totals": [
          {
            "values": [
              "6",
              "7",
              "4",
              "0",
              "137",
              "5501.0",
              "137",
              "0",
              "0.0"
            ]
          }
        ],
        "rowCount": 3,
        "minimums": [
          {
            "values": [
              "1",
              "1",
              "0",
              "0",
              "6",
              "135.0",
              "6",
              "0",
              "0.0"
            ]
          }
        ],
        "maximums": [
          {
            "values": [
              "4",
              "4",
              "4",
              "0",
              "111",
              "5100.0",
              "111",
              "0",
              "0.0"
            ]
          }
        ],
        "isDataGolden": true
      }
    }
  ]
}

我想將其轉換為列 header:dimensions 和 metric header 條目名稱將成為列名稱及其值的形式,即 data.rows.dimensions 和 metrics.values 成為相應的值

ga:date ga:campaign ga:country  ga:browser  ga:deviceCategory   ga:sourceMedium ga:socialNetwork    ga:region   ga:users    ga:sessions ga:newUsers : (column names)
20200316    (not set)   India   Chrome  desktop (direct) / (none)   (not set)   Tamil Nadu  1   1   1 :(values)

如果您可以使用集成帳戶,我建議創建具有所需結構的平面文件架構,並在邏輯應用程序中轉換 xml,然后應用平面文件編碼。

否則 function 應用程序應該可以解決您的問題

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM