Wie gebe ich diesen JSON-Wert aus, bei dem der Schlüssel mit einer Zahl beginnt?
Nehmen Sie diese json Antwort:
{
"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
}
]
}
Ich bin ratlos, wie man die avatarUrls-> 16x16 von oben bekommt. Ich habe alles andere ziemlich einfach mit Befehlen wie:
$decoded = json_decode($result);
$decoded->votes; //returns # of votes
$decoded->voters->name; //returns the name
Aber wie bekomme ich den 16x16 Wert? Ich erhalte eine Fehlermeldung, wenn ich Folgendes versuche:
$decoded->voters->avatarUrls->16x16;