Ecommerce Shopify WordPress Discussion

"JSON-LD Parsing Error in Shopify's featured-product.liquid: 'Missing } or Object Member Name'"

I'm currently working on a Shopify site and facing a challenging issue with JSON-LD syntax within the featured-product.liquid template. My goal is to correctly implement structured data for our product pages, but I'm encountering a persistent JSON-LD parsing error. The specific error I'm getting from the Structured Data Testing Tool is: "Missing '}' or object member name." This error suggests there's a syntax issue in my JSON-LD script, likely related to improper formatting, missing brackets, or incorrect placement of object members. The problematic section of the script seems to involve the integration of Shopify's Liquid template language with JSON-LD, particularly around conditional statements and variable interpolations. Here's the segment of the code where I believe the error is occurring: enter image description here liquid Copy code <script type="application/ld+json"> { "@context": "http://schema.org/", "@type": "Product", "name": {{ product.title | json }}, "url": {{ request.origin | append: product.url | json }}, {% if seo_media -%} "image": [ {{ seo_media | image_url: width: seo_media.preview_image.width | prepend: "https:" | json }} ], {%- endif %} "description": {{ product.description | strip_html | json }}, {% if product.selected_or_first_available_variant.sku != blank -%} "sku": {{ product.selected_or_first_available_variant.sku | json }}, {%- endif %} "brand": { "@type": "Brand", "name": {{ product.vendor | json }} }, "offers": [ {%- for variant in product.variants -%} { "@type" : "Offer", {%- if variant.sku != blank -%} "sku": {{ variant.sku | json }}, {%- endif -%} {%- if variant.barcode.size == 12 -%} "gtin12": {{ variant.barcode }}, {%- endif -%} {%- if variant.barcode.size == 13 -%} "gtin13": {{ variant.barcode }}, {%- endif -%} {%- if variant.barcode.size == 14 -%} "gtin14": {{ variant.barcode }}, {%- endif -%} "availability" : "http://schema.org/{% if variant.available %}InStock{% else %}OutOfStock{% endif %}", "price" : {{ variant.price | divided_by: 100.00 | json }}, "priceCurrency" : {{ cart.currency.iso_code | json }}, "url" : {{ request.origin | append: variant.url | json }} }{% unless forloop.last %},{% endunless %} {%- endfor -%} ] } </script> I've tried various approaches to fix this, such as ensuring correct JSON formatting, checking for missing commas or brackets, and verifying the placement of Liquid code blocks. However, the error persists. I'm seeking guidance on the following: How should Shopify Liquid variables be correctly integrated within a JSON-LD structure to avoid syntax errors? Are there specific formatting rules or considerations for JSON-LD in Shopify templates that I might be missing? Any advice or best practices for troubleshooting and resolving this type of JSON-LD parsing error in a Shopify environment? Any insights or suggestions from the community would be incredibly helpful in resolving this issue. Thank you! In attempting to resolve the JSON-LD parsing error in the Shopify featured-product.liquid template, I've conducted several trials and checks. Here's a summary of what I've tried, my expectations, and the actual outcomes: Attempts Made: Syntax Verification: I thoroughly examined the JSON-LD structure for common syntax errors like missing commas, misplaced brackets, and incorrect quotation marks. My expectation was that correcting these would resolve the error. Liquid Variables Integration: I paid special attention to how Shopify Liquid variables were integrated within the JSON-LD script. I ensured that they were correctly formatted and placed within the script. Conditional Statement Formatting: Since the error suggested a missing bracket or object name, I focused on the Liquid conditional statements ({% if %} blocks) to ensure they were not disrupting the JSON structure. Expectations: I expected that careful syntax correction and proper formatting of Liquid variables would eliminate the parsing error. I anticipated that the Structured Data Testing Tool would recognize the JSON-LD script as valid after these adjustments. Actual Results: Despite the syntax corrections and proper formatting of Liquid variables, the JSON-LD parsing error persisted. The Structured Data Testing Tool continued to report the same error: "Missing '}' or object member name," suggesting that the issue might be more complex or related to specific nuances of integrating Liquid with JSON-LD in Shopify. In summary, while I expected my attempts to rectify the syntax and integration of Liquid variables within the JSON-LD script to resolve the parsing error, the issue persisted, indicating a need for further insight or a different approach.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.