getAllAddressBooksForUser(); $addressBooksMetaData = array(); $contacts = array(); foreach($addressBooks as $addressBook) { $addressBooksMetaData[] = $addressBook->getMetaData(); foreach($addressBook->getChildren() as $contact) { $response = Utils\JSONSerializer::serializeContact($contact); if($response !== null) { $contacts[] = $response; } } } \OCP\JSON::success(array( 'data' => array( 'addressbooks' => $addressBooksMetaData, 'contacts' => $contacts, //Utils\JSONSerializer::serialize($contacts), 'is_indexed' => \OCP\Config::getUserValue(\OCP\User::getUser(), 'contacts', 'contacts_indexed', 'no') === 'yes' ) ));