Skip to main content
May 12, 2013
Answered

Getting name of key?

  • May 12, 2013
  • 1 reply
  • 540 views

Gidday

I have json data returning from my server, and then I decode it.

In php, I have unique names for the array sent back based on the result of the transaction...

$returnArray['links'] = $links;

$returnArray['msg'] = 'no matches for that code or name';

$returnArray['error'] = '3555';

(only one will ever be sent back at once)

In as3, I want to set up a switch based on the key name of the returned object...

switch (returnedServerData.nameofit-eg-links-or-msg-etc)

...so that I can set up my processing based on whether it's an error, link, msg etc

What do I type after returnedServerData. to access the name of that key?

Thanks guys

This topic has been closed for replies.
Correct answer kglad

you can use:

for(var s:String in returnedServerData){

switch(s){

.

.

.

}

}

1 reply

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
May 12, 2013

you can use:

for(var s:String in returnedServerData){

switch(s){

.

.

.

}

}

May 13, 2013

Ooo - that did the trick - thanks kGlad.

kglad
Community Expert
Community Expert
May 13, 2013

you're welcome.