操纵复杂对象

时间:2016-09-24 03:09:02

标签: javascript

如果有错误,有人可以帮我解决这个问题吗?

var myMusic = [ {  "artist": "Billy Joel",
                "title": "Piano Man",
                "release_year": 1973,
                "formats": [ 
                            "CS", 
                            "8T", 
                            "LP" ],
                "gold": true
             },

             [ {  "artist": "Paco de Lucia",
                "title": "Live in America",
                "release_year": 1992,
                "formats" : ["formats": [ 
                            "CS", 
                            "8T", 
                            "LP" ]]


             } ]]; 

3 个答案:

答案 0 :(得分:1)

问题出在这一部分:

"formats": 
[
    "formats": 
    [ 
        "CS", 
        "8T", 
        "LP" 
    ]
]

由于外部"格式"是一个数组,它不能有一个键"格式"和这样的数组值。

答案 1 :(得分:0)

您的语法已关闭,请尝试以下操作:

            {  "artist": "Billy Joel",
                        "title": "Piano Man",
                        "release_year": 1973,
                        "formats": [ 
                                    "CS", 
                                    "8T", 
                                    "LP" ],
                        "gold": true

            },


            {  
                "artist": "Paco de Lucia",
                "title": "Live in America",
                "release_year": 1992,
                "formats" : [  "CS", "8T", "LP" ]


             } 
             ]; 

答案 2 :(得分:-3)

您好,谢谢大家的一切,答案就在这里,谢谢大家:

var myMusic = [{" artist":" Billy Joel",                     " title":" Piano Man",                     " release_year":1973,                     "格式":[                                 " CS&#34 ;,                                 " 8T&#34 ;,                                 " LP" ]                     "黄金":是的                  },

           {
   "artist": "Paco de lucia", 
   "title": "la fabuloda guitarra de paco de lucia", 
   "release_year": 1967, 
   "formats": [
      "CD", 
      "Cassette", 
      "LP"
    ]
  }

];