XboxLeaders / XboxLiveAPI

[DEPRECATED] Please visit https://xboxapi.com for API services.
http://www.xboxleaders.com
MIT License
117 stars 26 forks source link

Friends Response Data wrapped in [ ] brackets #75

Closed KindaIntellectual closed 10 years ago

KindaIntellectual commented 10 years ago

I'm trying to grab the friends of my xuid but the JSON returns as invalid due to the [ ] brackets...

I admit I'm a complete noob at coding so if this is what it is supposed to do, or if there is some super simple way to fix this that I can't find please point me in the right direction!

Thank you

KindaIntellectual commented 10 years ago

Wait ok,

Does the friends results start with [ because the array itself is 'friends'? i.e. friends[0], friends[1], etc?

djekl commented 10 years ago

The JSON is correct as its using the internal function json_encode(). Please see https://github.com/XboxLeaders/XboxLiveAPI/blob/master/src/includes/classes/base.class.php#L519-L529

Within JSON its like Javascript, [] is an array and {} is an object. Please read up on how to use JSON - json_encode() and json_decode().

Closing as this is not an issue with the API.

KindaIntellectual commented 10 years ago

Thanks for such a fast reply. I know that the brackets make it an array, but I can't call the indexes of an array without a name, i.e. friends[0]. But in the output file there isn't one it just starts with [

I assumed it was an issue with the api since a Json validity checker returned the code/link as invalid due to it starting with [

So my question still remains, how do I call the indexes of this array? Sorry for such a dumb question...

The JSON is correct as its using the internal function `json_encode(). Please see https://github.com/XboxLeaders/XboxLiveAPI/blob/31248425a04d92a95b1fda7a3ec1de761875123e/src/includes/classes/base.class.php#L519-L529

Within JSON its like Javascript, [] is an array and {} is an object. Please read up on how to use JSON.

Closing as this is not an issue with the API.

— Reply to this email directly or view it on GitHub https://github.com/XboxLeaders/XboxLiveAPI/issues/75#issuecomment-52281949 .