Matt
Matt

Reputation: 13

Invalid JSON in tag 'Schema'

I am new to creating sections in Shopify and I am getting an invalid JSON in tag 'schema' error. I am trying to create a static section in my footer with a heading and image that links with a URL. Any help will be much appreciated.

{% 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 %}

Upvotes: 1

Views: 6403

Answers (2)

drip
drip

Reputation: 12943

There are too many issues with your JSON before we begin with the section issue first.

Validate your JSON here: https://jsonformatter.curiousconcept.com/

Here are some of the issues:

  • there are trailing , that shouldn't be there, example "default": "Enter heading text here", / "default": "Enter url here",
  • you have missing quotes - example id" / footer-image"

As for the Shopify section issue, URL fields, doesn't have a default field, so this is wrong "default": "Enter url here",.

Your section JSON should look like this:

{% 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 %}

Upvotes: 2

Sean S.
Sean S.

Reputation: 116

You are missing some double quotes and also you shouldn't have any commas on the last element.

On a side note, elements with type: url do not accept "default" parameter. Here's the fixed code which should work for you.

{% 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 %}

Upvotes: 1

Related Questions