Json lint不会验证我的代码。你知道为什么吗?
这是更新后的代码。它是一个对象,包括学校和在线教育。
var education ={
"schools": [
{
"name": "University of Hertfordshire",
"location": "Hertfordshir e, UK",
"degree": "Masters",
"Major": ["Computer Science"],
"graduation": "2017 (expected)"
},
{
"name": "University of Applied Sciences",
"location": "Jena, German",
"degree": "Diplom",
"Major": ["Business Administration and Information Systems"],
"graduation": "2010"
}
]
} ,
"onlineCourses": [
{
"title": "Javascript Syntax",
"school": "Udacity",
"dates": "May 2016"
}]
}发布于 2016-05-18 11:19:19
{
"schools": [{
"name": "University of Hertfordshire",
.....
}, {
"name": "University of Applied Sciences",
.....
}]
}, {
"onlinecourse": [{
"title": "Javascript Syntax",
....
}]
}这里有两个需要放在[]内部的对象,比如
[
{
"schools": [{
"name": "University of Hertfordshire"
.....
}, {
"name": "University of Applied Sciences"
....
}]
}, {
"onlinecourse": [{
"title": "Javascript Syntax"
.....
}]
}
]编辑
在更新后的代码中
{
"schools": [
{
"name": "University of Hertfordshire"
.....
},
{
"name": "University of Applied Sciences"
.....
} ]
} ,
"onlineCourses": [
{
"title": "Javascript Syntax"
......
}]
}请注意,schools之后的}数组充当对象结束标记,并且在onlinecourse之前没有{来提示解析器onlinecourse是另一个对象的一部分,并且所有这些混乱中的bcoz,解析器认为您有多个根元素。以下是解决方案:
[ // json is contained in an array bcoz there are multiple objects
{
"schools": [
{
"name": "University of Hertfordshire"
},
{
"name": "University of Applied Sciences"
}
]
},{ // the `}` your code was missing
"onlineCourses": [
{
"title": "Javascript Syntax"
}]
}
] // end of json array当然,在验证时将注释从json中删除,因为它们在json中是不允许的。
发布于 2016-05-18 14:15:39
它看起来像是在关闭学校数组的]之后出现了一个杂乱的}。
{
"schools": [
....
]流浪==> }
,
"onlineCourses": [
{
"title": "Javascript Syntax",
"school": "Udacity",
"dates": "May 2016"
}]
}如前所述,请确保检查错误
https://stackoverflow.com/questions/37289612
复制相似问题