【问题标题】:Invalid JSON in tag 'Schema'标签“架构”中的 JSON 无效
【发布时间】:2020-09-11 01:15:59
【问题描述】:

我是在 Shopify 中创建部分的新手,并且在标签“架构”错误中收到无效的 JSON。我正在尝试在页脚中创建一个静态部分,其中包含与 URL 链接的标题和图像。任何帮助将不胜感激。

{% schema %}
  {
    "name": "Footer Image",
    "class": "image",
    "settings":     [
                {
            "id":"footer-image-heading",
            "type":"text",
            "label":"footer-image-heading",
            "default": "Enter heading text here",
        },

                {
            id":"footer-image",
            "type":"image_picker",
            "label":footer-image",
            
        },

                {
            id":"footer-image-url",
            "type":"url",
            "label":"footer-image-url",
            "default": "Enter url here",
            
        },
    ]
}
{% endschema %}

【问题讨论】:

    标签: json schema shopify liquid


    【解决方案1】:

    在我们首先开始部分问题之前,您的 JSON 存在太多问题。

    在此处验证您的 JSON:https://jsonformatter.curiousconcept.com/

    这里有一些问题:

    • 后面有不应该出现的,,例如"default": "Enter heading text here", / "default": "Enter url here",
    • 您缺少引号 - 例如 id" / footer-image"

    关于 Shopify 部分的问题,URL 字段没有默认字段,所以这是错误的"default": "Enter url here",

    您的 JSON 部分应如下所示:

    {% schema %}
      {
        "name": "Footer Image",
        "class": "image",
        "settings":     [
            {
                "id":"footer-image-heading",
                "type":"text",
                "label":"footer-image-heading",
                "default": "Enter heading text here"
            },
    
            {
                "id":"footer-image",
                "type":"image_picker",
                "label":"footer-image"
            },
    
            {
                "id":"footer-image-url",
                "type":"url",
                "label":"footer-image-url"
            }
        ]
    }
    {% endschema %}
    

    【讨论】:

      【解决方案2】:

      您缺少一些双引号,并且最后一个元素上不应该有任何逗号。

      附带说明,类型为 url 的元素不接受“默认”参数。这是应该为您工作的固定代码。

      {% schema %}
          {
              "name": "Footer Image",
              "class": "image",
              "settings":     [
                  {
                      "id": "footer-image-heading",
                      "type": "text",
                      "label": "footer-image-heading",
                      "default": "Enter heading text here"
                  },
                  {
                      "id": "footer-image",
                      "type": "image_picker",
                      "label": "footer-image"
      
                  },
                  {
                      "id": "footer-image-url",
                      "type": "url",
                      "label": "Enter url here"
                  }
              ]
          }
      {% endschema %}
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-04-21
        • 1970-01-01
        • 2015-12-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多