I'm making an app that sends a request to my game website and pulls some data in JSON format. The data will be the player's account information, which would be an array with maybe 10-12 string key/value pairings. I want to make a response checker to validate that the JSON retrieved contains the needed data or if the request failed for some reason.
What I'm thinking is the JSON should be response of two arrays from the website.
Array 1 would have keys:
-"Status": 1 or 0 from the server for depending if the request was correct.
-"ErrorMessage": error message describing if any error occurred.
Array 2 would simply be an array of the players profile data:
"Player name" = player1 "Player gold" = 5000, etc Is this the right way to do it?
My options for received responses are:
-token was invalid
-token didn't exist
-token expired
-the request was correct but the access was denied (ie: tried to access an account off the wrong token, tried to attack a player that wasn't attack able, etc)
-the request correct returning all of the needed data.
If the response is one of the first 3 options should I also have a key in the first array called "tokenError"? Check if that is nul before looking for anymore data writhin the response?