json中显示错误

时间:2014-10-13 20:40:12

标签: javascript json

我是javascript的初学者,我正在为网站构建一个json代码。问题是为样式显示错误消息,但我在代码中使用了样式。错误消息是:` 1:错误的template.json:期望属性名称:第24行第2列(char 530) 2:我们在template.json的顶层遇到以下错误(缺少属性样式。)

名称是json文件是template.json,我也使用了两个图像。没有使用变量,但我已经创建了一个空间供将来使用。

{
    "id": "first-123",
    "name": "Get Paid",
    "mobile": true,
    "notes": "Initial import; first pass.",
    "syntax": 4,
    "version": 1.00,
    "style": 
    {
         "replacements": 
         [
             {
                "type": "color",
                "name": "Background Color",
                "find": "#FFFFFE"
              }
         ]
     },
    "elements":
         [
              {
                 "type": "image-link",
                 "id": "img/34769901.jpg",
                 "name": "Example 7 Image Link",
                       "data": 
                          {
                              "max-width": 1340
                          },

              {
                 "type": "image-link",
                 "id": "img/34769901.jpg",
                 "name": "Example 7 Image Link",
                 "data": 
                          {
                               "max-width": 1340
                          },


               }
          ],
    "variables": {}
}

2 个答案:

答案 0 :(得分:1)

你也错过了一个结束括号,改变了

"elements":
     [
          {
             "type": "image-link",
             "id": "img/34769901.jpg",
             "name": "Example 7 Image Link",
                   "data": 
                      {
                          "max-width": 1340
                      },

          {
             "type": "image-link",
             "id": "img/34769901.jpg",
             "name": "Example 7 Image Link",
             "data": 
                      {
                           "max-width": 1340
                      },


           }
      ],

"elements":
     [
          {
             "type": "image-link",
             "id": "img/34769901.jpg",
             "name": "Example 7 Image Link",
                   "data": 
                      {
                          "max-width": 1340
                      }
          },

          {
             "type": "image-link",
             "id": "img/34769901.jpg",
             "name": "Example 7 Image Link",
             "data": 
                      {
                           "max-width": 1340
                      }


           }
      ],

答案 1 :(得分:0)

删除数组/哈希

中最后一个元素后面的尾随逗号
   "max-width": 1340
 }