var bio = {
"name": "Belphy Baby",
"role": "student",
"contacts": {
"mobile": "9567166100",
"email": "belphy16@gmail.com",
"github": "belphy16",
"location": "kottayam"
},
"welcome message": "and miles to go before i sleep",
"skills": ["leadership", "enthusiastic", "learning"],
"bioPic": "images/fry.jpg"
}
$("#main").append(bio);
导致错误:
第1行的解析错误: var bio = {" name": ^ 期待' STRING',' NUMBER',' NULL'' TRUE',' FALSE',' {',' [',得到' undefined'
答案 0 :(得分:1)
输入应该只是JSONLint.com
的JSON {
"name": "Belphy Baby",
"role": "student",
"contacts": {
"mobile": "9567166100",
"email": "belphy16@gmail.com",
"github": "belphy16",
"location": "kottayam"
},
"welcome message": "and miles to go before i sleep",
"skills": ["leadership", "enthusiastic", "learning"],
"bioPic": "images/fry.jpg"
}
编辑:
答案基于OP的first revision。请注意他提供的image。
他得到的错误来自滥用网站的JSON验证服务。
正如服务名称所示,它验证了JSON文件的语法。
我们的OP代码包含JavaScript的提示。如果在JSONLint输入,它将给我们他的错误;声明应该是JSON输入有错误。