Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在制作一个用 jquery 解析 json 的脚本,但 json 中的相同键有一个哈希字符:
"image":[{"#text":"aaaaaaaaaaaaa","size":"bbbbbbbbbbbb"}
所以javascript会产生错误
$.each(item, function(y,img){ alert(y+" ----- "+img.#text+" "+img.size); });
我怎样才能避免它?
尝试使用[]符号访问对象成员:
[]
alert(y + " ----- " + img['#text'] + " " + img.size);