Group JSON Response if they are the same category

I have been working on a live score app, with api-football, okay right I get the response for the fixture fine but here comes the problem I couldn’t be able it was never documented how to group the matches by the leagues they belong to. So I have to build it.

So I will go through how I build this if someone comes across the same problem not just using the API but anything related this to. This will help you.

I have the files uploaded to my github account @ https://github.com/Benpaul320/geo_football_fixture_group so you can download and go through how it is done.

Moreover, I will explain every line of the code

Firstly, get the response from the API, but to speed things up, i just download the response so I can code offline and avoid making the request as much as i can. So import the JSON file which is also attached to the document

Then we have to decode the JSON string

* Loop through the array, this is important because we are trying to re-modify the array and making the league id the primary index of the array

Sore the newly created array

So I created a function to group the array to the category they belong to

Call the function, pass the array and league id as parameter

After that print the new array, now you have the new array which all grouped to the category they belong to.

help the computer