I'm creating a google chrome extension that will use some data that are stored inside a JSON
file. I need to compose a team of 11 members that needs to be extracted from the processed JSON
file, but I don't know how to proceed. After I've parsed the file, I want that for every team position there are only x team members. For example, I need to randomly select one Goalkeeper, three, four or five defenders, three four or five midfield and one, two or three attackers. With PHP
I'm able to do that without problems, but I'm not very experienced with javascript and I need help. Is there any function or any way to achieve this?
JSON
{
"player_id":3,
"player_surname":"Immobile",
"player_name":"Ciro",
"player_number":17,
"team_name":"Lazio",
"team_abbreviation":"LAZ",
"role_abbreviation":"A",
"role_name":"Attaccante",
"quotation":62,
}
JS
const uri = 'api/players_.json';
$.getJSON(uri, function(data){
// code stuff here
});