Hey guys, I pulled in some data from last year and suddenly my app is crashing. I narrowed it down to one player and found an interesting item in his data. Brian Westbrook hasn't signed with a team yet this year and when you look at his data for a team from last year, in "fantasy_content.league.players.0.player", in JSON format, you get "status" instead of "editorial_player_key".
When digging through an API's JSON output, I usually loop through and get stuff from the same place on each loop pass. When something is out of place like this, it crashes the loop, crashing the app.
This is the first time I've seen this in the Fantasy Sports API, but it troubles me that it shows up at all. Maybe I'm accessing the JSON data wrong, but currently I rely on everything to be in the same position. Is this unwise of me? Is there a better way to access JSON data?
Our JSON support is a bit spotty -- another guy on this forum noted that it sometimes produces weirdly indexed collections because we're mixing list-like elements (multiple <player> blobs, for instance) with associative key/values like count=x. I haven't quite sorted out what to do about that, so for right now, JSON has a bit of a buyer-beware label on it.
In your case, though, unless I'm understanding the JSON output incorrectly, it really seems like you ought to be getting the player data as a hash, not an array. ie, you should be asking for player. editorial_player_key if you want that, not player. If that's not how it's coming through, then yup, we probably have another JSON bug and you might be better off using the XML format and parsing through it. I'll definitely look through the JSON to see if I can fix it up, but XML is probably a safer bet if you want a working application sooner.