我有以下的JSON:访问阵列值
{
"responseHeader":{
"params":{
"facet":"true",
"fl":"city",
"facet.mincount":"1",
"indent":"on",
"start":"0",
"q":["*:*",
"*:*"],
"wt":"json",
"rows":"12"}},
"response":{"numFound":1,"start":0,"docs":[
{"city":"lathum"}]
},
"facet_counts":{
"facet_fields":{
"hasphoto":[
"true",61,
"false",5],
"hasvideo":[
"false",51,
"true",15],
"rating_rounded":[
"0.0",62,
"10.0",3,
"8.0",1]},
"facet_ranges":{}}}
我不知道是否有可能基于属性名称来选择一个值,在我的情况,我想选择多少hasphoto
的值为true
,这将是61. 请注意,true
值并不一定是hasphoto下的第一个列表,true
和false
按出现次数排序。
我想直接得到值,而不必循环通过它....这有可能吗?
我想:
response.facet_counts.facet_fields['hasphoto']['true']
和
response.facet_counts.facet_fields.hasphoto['true']
但都返回undefined
。
你或许应该指出哪些语言你正在使用。 FORTRAN中的JSON支持非常神秘。 –