I have an app that does some authentication using Google Accounts. As a response to my request , Google sends the following JSON
{
"id": "ID",
"name": "NAME",
"given_name": "GiVEN NAME",
"family_name": "FAMILY_NAME",
"link": "https://plus.google.com/ID",
"picture": "https://PHOTO.jpg",
"gender": "GENDER",
"locale": "LOCALE"
}
The problem is that many google accounts don't have all those details filled out. So in most cases the JSON looks like
{ "id": "ID", "locale": "LOCALE" }
So in order to get the data I need, I need to check each JSON to see if the name,picture,gender etc. are provided and if not, prompt the user to enter those data items.To do this I tried checking if the JSONObject.getString("name") etc. was null. But instead of completing the if condition, the app skips to an JSON exception.
So what I need is a way to add the JSON data Google sends me to an Associative Array with the keys and values and check through that array to see if the data I need is there without getting an JSON exception.Do you know any way of doing that?
Sorry for my bad english.