Problems with Dynamic Schema Markup

I'm having trouble with making my schema markup dynamic, I've formatted it with the guidelines but very time I validate the code, I get an error saying "JSON-LD
Syntax error: value, object or array expected."

I'm unsure of how to fix it. Heres the code below. Thanks in advance

<script type="application/ld+json">
{
  "@context": "http://schema.org",
  "@type": "Product",
  "name": document.querySelector("#product-title").innerText,
  "description": document.querySelector("#product-description").innerText,
  "image": document.querySelector("#product-image").src,
  "url": window.location.href,
  "sku": document.querySelector("#product-sku").innerText,
  "brand": document.querySelector("#product-brand").innerText,
  "offers": {
    "@type": "Offer",
    "availability": "http://schema.org/" + document.querySelector("#product-availability").innerText,
    "price": document.querySelector("#product-price").innerText,
    "priceValidUntil": "2019-12-31",
    "priceCurrency": "Currency Code",
    "url": window.location.href
    },
  "aggregateRating": {
    "@type": "AggregateRating",
    "bestRating": "5",
    "ratingValue": "5",
    "reviewCount": "3"
    },
  "review": [
    {
      "@type": "Review",
      "author": document.querySelector("#review-author-1").innerText,
      "reviewRating": {
        "@type": "Rating",
        "bestRating": "5",
        "ratingValue": document.querySelector("#review-rating-1").innerText,
        "worstRating": "1"
      },
      "reviewBody": document.querySelector("#review-body-1").innerText
    },
    {
      "@type": "Review",
      "author": document.querySelector("#review-author-2").innerText,
      "reviewRating": {
        "@type": "Rating",
        "bestRating": "5",
        "ratingValue": document.querySelector("#review-rating-2").innerText,
        "worstRating": "1"
      },
      "reviewBody": document.querySelector("#review-body-2").innerText
    },
    {
      "@type": "Review",
      "author": document.querySelector("#review-author-3").innerText,
      "reviewRating": {
        "@type": "Rating",
        "bestRating": "5",
        "ratingValue": document.querySelector("#review-rating-3").innerText,
        "worstRating": "1"
      },
      "reviewBody": document.querySelector("#review-body-3").innerText
    }
  ]
}
</script>

I've tried changing format and all sort of things.



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations