factorization of code (to get the contact list in json)