【问题标题】:Edge & Json: copy a letter of a keyEdge & Json:复制一个键的字母
【发布时间】:2018-04-19 21:48:58
【问题描述】:

当我从服务器获取 Json 时,我只会在边缘遇到问题。 这是我的 json :

{"user":[{"pk":10,"user_group":[1,2,6],"uname":"5555678910","upass":"","first_name":"tutu","last_name":"","country":1,"other_countries":[],"brands":[]},{"pk":7,"user_group":[1,2],"uname":"aaa","upass":"","country":1,"other_countries":[5],"brands":[1]},{"pk":8,"user_group":[1],"uname":"222","upass":"","first_name":"","last_name":"","country":1,"other_countries":[],"brands":[]}]}

(您可以复制/粘贴到:http://json.parser.online.fr/

而且只有在 Edge 上,我得到了这个 json:

{"user":[{"pk":10,"user_group":[1,2,6],"uname":"5555678910","upass":"","first_name":"tutu","last_name":"","country":1,"other_countries":[],"brands":[]},{"pk":7,"user_group":[1,2],"uname":"aaa","upass":"","country":1,"other_countries":[5],"braands":[1]},{"pk":8,"user_group":[1],"uname":"222","upass":"","first_name":"","last_name":"","country":1,"other_countries":[],"brands":[]}]}

“品牌”键给了我“品牌”,当我将键更改为“qwerty”时,我得到了“qweerty”。

只有第二个用户,其余的都有正确的密钥。

【问题讨论】:

  • 我找不到任何密钥 qwerty 并且我得到品牌就好了
  • 不,当我将关键“品牌”的名称更改为“qwerty”时,我得到了“qweerty”
  • 当我使用 jsonCallback.user[j].brands.length 时,我遇到如下错误:“无法获取未定义或空引用的属性‘长度’”,因为第二个对象有: jsonCallback.user[1].braands

标签: javascript jquery json key microsoft-edge


【解决方案1】:

今天,Edge 完美运行。 我已经使用 hasOwnProperty 来检查 json 是否有“品牌”或“品牌”。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-28
    • 1970-01-01
    • 2018-07-07
    • 2014-11-26
    • 1970-01-01
    • 2013-06-11
    相关资源
    最近更新 更多