接受这个json回复:
{
"self":"http://macpro.local:2990/jira/rest/api/2/issue/CSS-4/votes",
"votes":2,
"hasVoted":true,
"voters":[
{
"self":"http://macpro.local:2990/jira/rest/api/2/user?username=admin",
"name":"admin",
"avatarUrls":{
"16x16":"http://macpro.local:2990/jira/secure/useravatar?size=small&avatarId=10062",
"48x48":"http://macpro.local:2990/jira/secure/useravatar?avatarId=10062"
},
"displayName":"admin",
"active":true
},
{
"self":"http://macpro.local:2990/jira/rest/api/2/user?username=timn_1",
"name":"timn_1",
"avatarUrls":{
"16x16":"http://macpro.local:2990/jira/secure/useravatar?size=small&avatarId=10062",
"48x48":"http://macpro.local:2990/jira/secure/useravatar?avatarId=10062"
},
"displayName":"User Two",
"active":true
}
]
}
我对如何从上面获取avatarUrls-> 16x16感到茫然。我用以下命令很容易地得到其他所有东西:
$decoded = json_decode($result);
$decoded->votes; //returns # of votes
$decoded->voters->name; //returns the name
但是如何获得16x16的价值?如果我尝试这个,我会收到错误:
$decoded->voters->avatarUrls->16x16;
答案 0 :(得分:4)
一如既往。
$decoded->voters->avatarUrls->{'16x16'}