【问题标题】:Shopify bulk query results parsingShopify 批量查询结果解析
【发布时间】:2022-08-03 19:25:08
【问题描述】:

我正在研究 shopify 集成,我正在尝试执行一些以 jsonl 格式返回数据的批量查询。 我仔细阅读了文档,我明白了这种格式背后的原理,但有一点我不明白:以下是我的 jsonl 文件的一部分,代表结果中的第一项

{\"id\":\"gid:\\/\\/shopify\\/Product\\/6755349070004\",\"options\":[{\"id\":\"gid:\\/\\/shopify\\/ProductOption\\/8677003133108\",\"name\":\"Città\",\"position\":1}],\"title\":\"Product title\",\"productType\":\"Concerto Live\"}
{\"id\":\"gid:\\/\\/shopify\\/ProductVariant\\/40163436363956\",\"price\":\"100.00\",\"title\":\"MIlano\",\"__parentId\":\"gid:\\/\\/shopify\\/Product\\/6755349070004\"}
{\"id\":\"gid:\\/\\/shopify\\/ProductVariant\\/40163436396724\",\"price\":\"100.00\",\"title\":\"Roma\",\"__parentId\":\"gid:\\/\\/shopify\\/Product\\/6755349070004\"}
{\"id\":\"gid:\\/\\/shopify\\/ProductVariant\\/40163436429492\",\"price\":\"100.00\",\"title\":\"Firenze\",\"__parentId\":\"gid:\\/\\/shopify\\/Product\\/6755349070004\"}
{\"id\":\"gid:\\/\\/shopify\\/Collection\\/272323707060\",\"description\":\"Product variant description\",\"title\":\"CONCERTI\",\"__parentId\":\"gid:\\/\\/shopify\\/Product\\/6755349070004\"}
{\"id\":\"gid:\\/\\/shopify\\/Collection\\/272323739828\",\"description\":\"Product variant description\",\"title\":\"LIVE\",\"__parentId\":\"gid:\\/\\/shopify\\/Product\\/6755349070004\"}
{\"id\":\"gid:\\/\\/shopify\\/Collection\\/273036607668\",\"description\":\"Product variant description\",\"title\":\"Product variant description\",\"__parentId\":\"gid:\\/\\/shopify\\/Product\\/6755349070004\"}

它是通过以下查询获得的

mutation {
  bulkOperationRunQuery(
    query: \"\"\"
          {
                    items: products{
                        pageInfo {
                          hasNextPage
                        }
                        edges {
                          cursor
                          node {
                            id
                            variants(first: 10) {
                              edges {
                                node {
                                  id
                                  price
                                  title
                                }
                              }
                            }
                            options(first: 5) {
                              id
                              name
                              position
                            }
                            title
                            collections(first: 8) {
                              edges {
                                node {
                                    id
                                  metafields(first: 5) {
                                    edges {
                                      node {
                                        id
                                        key
                                        namespace
                                        value
                                      }
                                    }
                                  }
                                  description
                                  title
                                }
                              }
                            }
                            productType
                            images(first: 2) {
                              edges {
                                node {
                                  src
                                }
                              }
                            }
                          }
                        }
                      }
                  }

    \"\"\"
  ) {
    bulkOperation {
      id
      status
    }
    userErrors {
      field
      message
    }
  }
}

所以第一行是“主”产品对象,第 2,3 和 4 行是变体,然后我们有集合,然后是图像:问题是,除了父级的 id,还有无法知道子行指的是哪个父级的属性。如果我想从中构建一个 json,例如,我怎么知道第二行是 products.variants 中的数组项?

    标签: shopify shopify-app jsonlines


    【解决方案1】:

    你解决这个问题如果是,那么请告诉我该怎么做。 任何回应都会赞赏

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-18
      • 2015-04-19
      • 2016-04-23
      • 1970-01-01
      • 1970-01-01
      • 2016-02-08
      • 2014-08-14
      相关资源
      最近更新 更多