使用其他类型内部的类型时,SDTT中的JSON-LD错误:“数组声明中缺少','或']'。

时间:2018-10-17 00:14:53

标签: json json-ld

我目前正在尝试使用WebSite通过JSON-LD来应用Organization@graph Schema.org,并且遇到了语法问题,我没有了解。我不是Java开发人员,而是HTML&CSS专家,所以我真的不知道发生了什么。

在Google的结构化数据测试工具中,第11行出现错误:

  

在数组声明中缺少“,”或“]”。

但是我已经经历了很多次,我无法理解问题。我试过重新排列所有括号,然后在各处移动内容,似乎每次消除错误时,都会出现另一个错误。这是到目前为止我获得的最好的代码版本。

在其他@type内使用@type时似乎出现了问题。

{
    "@context" : "http://schema.org",
    "@graph" : 
        [
            {
                "@type" : "WebSite", 
                "url" : "https://www.bcsauto.com", 
                "name" : "BCS Auto",
                "author" : 
                    [
                        "@type" : "Person",
                        "name" : "Justin Hilliard"
                    ],
                "description" : "Your NEW source for Late Model Camaro Parts & Accessories!",
                "publisher" : "Justin Hilliard ",
                "potentialAction" :
                    [ 
                        "@type" : "SearchAction", 
                        "target" : "https://shop.bcsauto.com/search.html?q={search_term}&go=Search", 
                        "query-input" : "required name=search_term"
                    ] 
            },
            {   
                "@type" : "Organization",
                "name" : "BCS Auto",
                "url" : "http://www.bcsauto.com",
                "logo" : "https://shop.bcsauto.com/files/images/logo.png",
                "foundingDate" : "2016",
                "founders": 
                [
                    {
                        "@type": "Person",
                        "name": "Justin Hilliard"
                    },
                ],
            }, 
                {   
                    "@type" : "ContactPoint",
                    "contactType" : "Sales",
                    "telephone" : "[+1-602-730-6415]",
                    "email" : "sales@bcsauto.com",
                    "areaServed" : "US"
                },
                {
                    "@type" : "ContactPoint",
                    "contactType" : "Customer Support",
                    "telephone" : "[+1-602-730-6415]",
                    "email" : "support@bcsauto.com",
                    "areaServed" : "US",
                    "sameAs" :
                        [
                            "https://www.facebook.com/OfficialBCSAuto",
                            "https://instagram.com/officialbcsauto",
                            "https://www.linkedin.com/company/bcsauto" 
                        ]
                }
        ]
}

2 个答案:

答案 0 :(得分:0)

            "author" : 
                [
                    "@type" : "Person",
                    "name" : "Justin Hilliard"
                ],
            "potentialAction" :
                [ 
                    "@type" : "SearchAction", 
                    "target" : "https://shop.bcsauto.com/search.html?q={search_term}&go=Search", 
                    "query-input" : "required name=search_term"
                ] 

[ ]用于数组,{ }用于对象。在上面的代码段中,您有对象,因此必须使用大括号而不是方括号。

            "founders": 
            [
                {
                    "@type": "Person",
                    "name": "Justin Hilliard"
                },
            ],

在上面的代码段中,您有一个仅包含一个对象的数组。无论是否保留数组(仅保留一个值,都不需要),都必须删除最后两个,,因为对象是数组中的最后一个值,而数组是其中的最后一个值父对象。

答案 1 :(得分:0)

由于@unor,我得以解决此问题!因为我不了解数组和对象,所以我混用了括号和花括号。

{
  "@context": "http://schema.org",
  "@graph": [
    {
      "@type": "WebSite",
      "url": "https://www.bcsauto.com",
      "name": "BCS Auto",
      "author": {
        "@type": "Person",
        "name": "Justin Hilliard"
      },
      "description": "Your NEW source for Late Model Camaro Parts & Accessories!",
      "publisher": {
        "@type": "Person",
        "name": "Justin Hilliard"
      },
      "potentialAction": {
        "@type": "SearchAction",
        "target": "https://shop.bcsauto.com/search.html?q={search_term}&go=Search",
        "query-input": "required name=search_term"
      }
    },
    {
      "@type": "Organization",
      "name": "BCS Auto",
      "url": "http://www.bcsauto.com",
      "logo": "https://shop.bcsauto.com/files/images/logo.png",
      "foundingDate": "2016",
      "founders": {
        "@type": "Person",
        "name": "Justin Hilliard"
      },
      "ContactPoint": [
        {
          "@type": "ContactPoint",
          "contactType": "Sales",
          "telephone": "[+1-602-730-6415]",
          "email": "sales@bcsauto.com",
          "areaServed": "US"
        },
        {
          "@type": "ContactPoint",
          "contactType": "Customer Support",
          "telephone": "[+1-602-730-6415]",
          "email": "support@bcsauto.com",
          "areaServed": "US",
          "sameAs": [
            "https://www.facebook.com/OfficialBCSAuto",
            "https://instagram.com/officialbcsauto",
            "https://www.linkedin.com/company/bcsauto"
          ]
        }
      ]
    }
  ]
}