I am struggling to convert a lengthy list into a JSON or JavaScript object using JavaScript. Despite searching online, I have not been able to find a suitable solution.
Afghanistan- 132
South Africa - 7560
Albania - 175
Germany - 230
Andorra - 370
This is just a snippet of the complete list, which is too long to manually convert.
The desired output after conversion should resemble this:
[
{
"id": 132,
"country_name":"Afghanistan"
},
{
"id": 7560,
"country_name":"South Africa"
},
{
"id": 175,
"country_name":"Albania"
},
{
"id": 230,
"country_name":"Germany"
},
{
"id": 370,
"country_name":"Andorra"
}
]