这里是 Json 文件
"data" : [
{
"mer" : "a",
"AName" : "Am",
"numProducts" : "69",
"p" : "1.21",
"color" : "#0b4977"
},
{
"mer" : "b",
"AName" : "Ma",
"numProducts" : "42",
"p" : "1.0",
"color" :"#1d94dd"
},
{
"mer" : "c",
"AName" : "An",
"numProducts" : "91",
"p" : "1.01",
"color" :"#09213a"
},
{
"mer" : "d",
"AName" : "A1",
"numProducts" : "91",
"p" : "1.01",
"color" :"#ffcc00"
},
{
"mer" : "egg",
"AName" : "B2",
"numProducts" : "91",
"p" : "1.01",
"color" :"#fcee21"
}
]
}
在这里,如果需要访问最后一个“mer”值,我会像 data[4].mer 一样进行操作,但是如果它与同一数据数组中的某个条件匹配,我想从 json 文件中访问特定值。
例如这里我有最后一个'mer'的“egg”值,现在我想访问它的特定颜色值。(#fcee21)我有什么办法动态地做到这一点吗?