首页 > 解决方案 > 标签“架构”中的 JSON 无效

问题描述

我是在 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 %}

标签: jsonschemashopifyliquid

解决方案


在我们首先开始部分问题之前,您的 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 %}

推荐阅读