ybqq_0221
2019-07-06 16:41
采纳率: 100%
浏览 2.7k
已采纳

json对象的属性值获取不了?为undefined?

var data1 = {
                "raster_metainfo": [0,0,0,0,0,0,0],
                "navigation_metainfo": [0,0,0,0,0,0,0],
                "thematic_metainfo": [0,0,0,0,0,0,0],
                "text_metainfo":  [0,0,0,0,0,0,0],
                "video_metainfo":  [0,0,0,0,0,0,0],
                "database_metainfo": [0,0,0,0,0,0,0],
                "service_metainfo":  [0,0,0,0,0,0,0]
            }
            jsonData = JSON.stringify(data1);

            var a ='navigation_metainfo';
                        console.log(data1.a);
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

4条回答 默认 最新

  • 听楼一夜雨 2019-07-06 16:48
    已采纳

    你已经吧对象转成字符串了

    var data1 = {
                    "raster_metainfo": [0,0,0,0,0,0,0],
                    "navigation_metainfo": [0,0,0,0,0,0,0],
                    "thematic_metainfo": [0,0,0,0,0,0,0],
                    "text_metainfo":  [0,0,0,0,0,0,0],
                    "video_metainfo":  [0,0,0,0,0,0,0],
                    "database_metainfo": [0,0,0,0,0,0,0],
                    "service_metainfo":  [0,0,0,0,0,0,0]
                };
                var a ='navigation_metainfo';
                console.log(data1.a);
                console.log(data1[a]);
    
    评论
    解决 无用
    打赏 举报
  • 查看更多回答(3条)

相关推荐 更多相似问题