How to access json object key with space

I have a json file, and the key of almost every object has a space between them, for their name and surname. Therefore, every time I try to call the value of this key, it says "undefined. How to get the values ​​to show?

Here is an example of my json file

{"Wojciech Szczesny":"yes","Lukasz Fabianski":"no","Emiliano Viviano":"no","Olivier Giroud":"yes","Per Mertesacker":"yes","Bacary Sagna":"yes","Laurent Koscielny":"no","Santi Cazorla":"yes","Mikel Arteta":"yes","Mesut \u00d6zil":"no","Kieran Gibbs":"yes","Aaron Ramsey":"no","Jack Wilshere":"no","Mathieu Flamini":"yes","Tomas Rosicky":"yes","Lukas Podolski":"yes","Nacho Monreal":"no","Theo Walcott":"no","Thomas Vermaelen":"yes","Carl Jenkinson":"no","Alex Oxlade-Chamberlain":"no","Serge Gnabry":"no","Kim Kallstrom":"no","Nicklas Bendtner":"no","Abou Diaby":"no","Park Chu-Young":"no","Emmanuel Frimpong":"no","Yaya Sanogo":"no","Ryo Miyaichi":"no","Hector Bellerin":"no","Chuba Akpom":"no","Isaac Hayden":"no","Gideon Zelalem":"no"} 

Here is my code

 $.ajax({ url:'ars.json', dataType:'json', cache: false, success: function(data) { var count = 0; arrayTesting.push(Object.getOwnPropertyNames(data[0])); for(var key in data) { //This line does not run at all if(data[key].Per Mertesacker){ count++; }else{} } //Nothing prints out in the console console.log(data[key].Per Mertesacker); } }); 
+7
json javascript jquery
source share
1 answer

Edit

 console.log(data[key].Per Mertesacker); 

to

 console.log(data[key]['Per Mertesacker']); 

Read Working with Objects

+14
source share

All Articles