I have a <select>
with a list of country <option>
s. I want to turn my list of country <option>
s into a file with an array of objects so I can import the array, and loop through it.
What I have:
<option data-code="US" value="USA">United States</option>
<option data-code="AU" value="Australia">Australia</option>
<option data-code="CA" value="Canada">Canada</option>
<option data-code="GB" value="United Kingdom">United Kingdom</option>
What I would like:
countries.js
var countriesList = [
{
"data-code": "US",
"name": "United States",
"value": "USA"
},
]
I know this has to be possible with Node in the command line, or python, something similar, but I must not be searching the right keywords. Even pointing to a resource or providing key words would be appreciated.