javascript - 我的 JSON 代码有什么问题?

标签 javascript json jslint

谁能告诉我为什么我的 JSON 文件在解析时抛出错误?我正在尝试使用卡图仪制作 map ?我使用 JSLINT 收到这些错误(如下所示)

{
  "proj": { "id": "sinusoidal", 
   "lon0": 134.25},
  "layers": [
    {
      "background": {"special": "sea"},
      "styles": {"fill": "lightblue"}
    },
    {
      "graticule": {"special": "graticule",
      "latitudes": 1,
      "longitudes": 1}
    },
     { "id": "Aus"
       "src": "myfile"
       "simplify": false
       }, 
    { "id": "trees",
      "src": "myfile",
      "simplify": true },
   {'id': 'crops'
      "src": "myfile",
      "simplify": true
   },
     { "id": "depth"
       "src": "myfile",
       "simplify": true
   },
   { "id": "states",
      "src": "myfile"}
  ],

  "export": {
    "width": "auto",
    "height": "auto"
  },
  "bounds": {
    "padding": 0.02,
    "mode": "bbox",
    "data": [92, -44, 181, -2],
    "crop": [112, -44, 154, -9]

  }
}

我使用 JSLINT 遇到的错误是

Line 14, column 8: Expected '}' to match '{' from line 13 and instead saw 'src'.
           "src": "myfile"

Line 14, column 13: Expected ']' to match '[' from line 3 and instead saw ':'.
           "src": "myfile"

Line 14, column 15: Expected '}' to match '{' from line 1 and instead saw 'D:/karto/Aus/Ausfull/Ausfull.shp'.
           "src": "myfile"

Line 15, column 8: Expected '(end)' and instead saw 'simplify'.
           "simplify": false

* 不明白如何解决这些错误?

最佳答案

字符串必须用双引号引起来,并且您错过了一些逗号

  {
        "proj": {
            "id": "sinusoidal",
                "lon0": 134.25
        },
            "layers": [{
            "background": {
                "special": "sea"
            },
                "styles": {
                "fill": "lightblue"
            }
        }, {
            "graticule": {
                "special": "graticule",
                    "latitudes": 1,
                    "longitudes": 1
            }
        }, {
            "id": "Aus",
                "src": "myfile",
                "simplify": false
        }, {
            "id": "trees",
                "src": "myfile",
                "simplify": true
        }, {
            "id": "crops",
                "src": "myfile",
                "simplify": true
        }, {
            "id": "depth",
                "src": "myfile",
                "simplify": true
        }, {
            "id": "states",
                "src": "myfile"
        }],

            "export": {
            "width": "auto",
                "height": "auto"
        },
            "bounds": {
            "padding": 0.02,
                "mode": "bbox",
                "data": [92, -44, 181, -2],
                "crop": [112, -44, 154, -9]

        }
    }

关于javascript - 我的 JSON 代码有什么问题?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23610721/

相关文章:

javascript - 我想用一个按钮更改文本

javascript - 将对象及其方法分配给原型(prototype)

java - 使用 jackson jersey 将复杂的 hashmap 转换为 JSON

javascript - JSLint - 导入包时出现问题

javascript - 是否可以在 node.js 的帮助下在 Windows 中将 JSLint 作为命令行运行?

javascript - 将 jQuery 代码转换为纯 JavaScript

javascript - Google 自定义搜索 - getElement 为 null - 无法访问 <gcse :. ..> 元素

javascript - 是否有关于如何填充 Revision.Description 以及在什么条件下填充的文档?

c# - 如何使用 C# 使用 HttpClient 发布 JSON?

javascript - 我的脚本在 JSLint 中失败