在 Talend 中使用 XPATH 从 Facebook Marketing API 中提取 JSON

Extract JSON from Facebook Marketing API using XPATH in Talend

目前我正在从 Facebook 营销中提取数据 API。 我在 Talend Studio 中使用 XPATH 查询通过 API.

获取 JSON

因为这是我使用 JSON 和 XPATH 的第一份工作,所以我需要一些有关以下提取的帮助:

起初我的一部分 JSON:

{
  "data": [
    {
      .
      .
      .
      "adsets": {
        "data": [
          {
           .
           .
           .
            "targeting": {
              "age_max": 60,
              "age_min": 18,
              "geo_locations": {
                "countries": [
                  "DE"
                ]
              },
              "facebook_positions": [
                "feed",
                "right_hand_column"
              ],
.
.
.

现在我想使用 XPATH 从 "facebook_positions" 中提取:

"/data/adsets/data/targeting/facebook_positions"

使用该 XPATH 查询我只得到 "feed" 作为我的结果,但我需要 "feed,right_hand_column" 因为没有像 ' "age_max": 60' 这样的值的键我不能提取正确的路径。

在此先感谢您的帮助!

最好的问候 钴

你试过了吗:-

//facebook_positions

//facebook_positions[1] -> 饲料

//facebook_positions[2] -> right_hand_column

示例:-

打开下方URL:

http://www.jsonquerytool.com/

{
    "data": [{
        "adsets": {
            "data": [{

                "targeting": {
                    "age_max": 60,
                    "age_min": 18,
                    "geo_locations": {
                        "countries": [
                            "DE"
                        ]
                    },
                    "facebook_positions": [
                        "feed",
                        "right_hand_column"
                    ]
                }
            }]
        }
    }]
}

Select 查询 JSON 为 :-

JSon

的 Xpath

将查询设为:-

//facebook_positions

点击运行