Null pointer exceptions avoided when creating json to send via gcm