Visit the list of U.S. state abbreviations on Wikipedia.
Sort the table by “status of region” to group the states together
Select the cells of all of the states (from “Alabama” to “Wyo.”) and press ⌘C to copy
Cut the TSV in your clipboard to two columns (name and two-letter code)
pbpaste | cut -d$'\t' -f1,4 | pbcopy
Convert the two-column TSV into line-delimited JSON:
pbpaste | perl -pne 's/^ *(.+)\t(.+)/{"name":"$1","code":"$2"}/' | pbcopy
Use jq to combine the lines into states-array.json
:
pbpaste | jq -rs > states-array.json
Use jq again to produce states-object.json
:
cat states-array.json | jq 'reduce .[] as $item ({}; . + {($item.code): $item.name})' \
> states-object.json