I am encountering an issue while trying to calculate the number of records in a JSON object, as I am getting an incorrect count.
Snippet
var jsonObject = {"d":"[{\"Country\":\"\",\"CountryCode\":\"\",\"Location\":\"\",\"Group\":\"\",\"RoomMailId\":\"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="efaa978c878e81888abd808082bb8a9c9bdeaf8b8a8280c18c8082">[email protected]</a>\",\"Description\":\"\",\"Telephone\":\"\",\"DisplayName\":\"ExchangeRoomTest1\",\"CondecoRoomId\":0,\"CondecoRoomName\":\"\",\"IsMapped\":false,\"LastSyncTimeLocal\":\"\"},{\"Country\":\"\",\"CountryCode\":\"\",\"Location\":\"\",\"Group\":\"\",\"RoomMailId\":\"<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b3f6cbd0dbd2ddd4d6e1dcdcdee7d6c0c781f3d7d6dedc9dd0dcde">[email protected]</a>\",\"Description\":\"\",\"Telephone\":\"\",\"DisplayName\":\"ExchangeRoomTest2\",\"CondecoRoomId\":0,\"CondecoRoomName\":\"\",\"IsMapped\":false,\"LastSyncTimeLocal\":\"\"}]"};
var keyCount = Object.keys(jsonObject.d).length
document.write(keyCount);
Result
489
Expected Result
2