這是我的代碼:<script>try { var ob = JSON.parse("{ ID: 1, 'Code':'001', 'Name':'john', 'HasParent':false, 'HasGrandParent':false, 'IsAgent':False }"); document.write(ob.Name);}catch(err) { document.write(err);}</script>這是錯(cuò)誤消息:Unexpected token I in JSON at position 2我不知道發(fā)生了什么。這里出了什么問題?==================感謝下面 JayTheKay 的回答。問題和修復(fù)是:對(duì)字符串使用雙引號(hào)布爾值是小寫的,所以“False”是錯(cuò)誤的,“false”是正確的這個(gè)第一個(gè)鍵名ID沒有用雙引號(hào)引起來
JSON 中位置 2 的意外標(biāo)記 I
慕絲7291255
2023-03-03 13:15:05