spatie/schema-org

generated schema is not as Google say in the documentation

core45 opened this issue · 2 comments

In the Google documentation (https://developers.google.com/search/docs/advanced/structured-data/product#guidelines)
they say the script on the page should look like this:

<script type="application/ld+json">
      {
        "@context": "https://schema.org/",
        "@type": "Product",
        "name": "Executive Anvil",
        "image": [
          "https://example.com/photos/1x1/photo.jpg",
          "https://example.com/photos/4x3/photo.jpg",
          "https://example.com/photos/16x9/photo.jpg"
         ],
        ...

But the schema generated by this package has escaped slashes like this:

<script type="application/ld+json">
      {
        "@context": "https:\/\/schema.org\/",
        "@type": "Product",
        "name": "Executive Anvil",
        "image": [
          "https:\/\/example.com\/photos\/1x1\/photo.jpg",
          "https:\/\/example.com\/photos\/4x3\/photo.jpg",
          "https:\/\/example.com\/photos\/16x9\/photo.jpg"
         ],
        ...

Why is that and shouldn't the script be generated as it is written by Google?

It's exactly the same, besides that this package isn't a Google wrapper but an object oriented package following the official specs by schema.org

I never said this is a Google wrapper. And by the way in schema.org how it looks is:

    <script type="application/ld+json">
    {
        "@context": "https://schema.org",
        "@type": "ItemList",
        "url": "http://example.com?filters%5Bprice%5D%5BLTE%5D=39600",
        "numberOfItems": "315",
        "itemListElement": [
            {
                "@type": "Product",
                "image": "http://example.com/c9/f1/a5fe6642-18d0-47ad-b038-6fca20f1c923.jpeg",
                "url": "http://example/brand_502/",
                "name": "Brand 502",
                "offers": {
                    "@type": "Offer",
                    "price": "4399 p."
                }
            },
            {
                "@type": "Product",
                "name": "..."
            }
        ]
    }
    </script>

No backslashes whatsoever.
So why on Earth they are added? What is the purpose?