-
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
Last active
March 14, 2023 20:13
Star
You must be signed in to star a gist
50 US states as JSON
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ | |
"name": "Alabama", | |
"code": "AL" | |
}, | |
{ | |
"name": "Alaska", | |
"code": "AK" | |
}, | |
{ | |
"name": "Arizona", | |
"code": "AZ" | |
}, | |
{ | |
"name": "Arkansas", | |
"code": "AR" | |
}, | |
{ | |
"name": "California", | |
"code": "CA" | |
}, | |
{ | |
"name": "Colorado", | |
"code": "CO" | |
}, | |
{ | |
"name": "Connecticut", | |
"code": "CT" | |
}, | |
{ | |
"name": "Delaware", | |
"code": "DE" | |
}, | |
{ | |
"name": "Florida", | |
"code": "FL" | |
}, | |
{ | |
"name": "Georgia", | |
"code": "GA" | |
}, | |
{ | |
"name": "Hawaii", | |
"code": "HI" | |
}, | |
{ | |
"name": "Idaho", | |
"code": "ID" | |
}, | |
{ | |
"name": "Illinois", | |
"code": "IL" | |
}, | |
{ | |
"name": "Indiana", | |
"code": "IN" | |
}, | |
{ | |
"name": "Iowa", | |
"code": "IA" | |
}, | |
{ | |
"name": "Kansas", | |
"code": "KS" | |
}, | |
{ | |
"name": "Kentucky", | |
"code": "KY" | |
}, | |
{ | |
"name": "Louisiana", | |
"code": "LA" | |
}, | |
{ | |
"name": "Maine", | |
"code": "ME" | |
}, | |
{ | |
"name": "Maryland", | |
"code": "MD" | |
}, | |
{ | |
"name": "Massachusetts", | |
"code": "MA" | |
}, | |
{ | |
"name": "Michigan", | |
"code": "MI" | |
}, | |
{ | |
"name": "Minnesota", | |
"code": "MN" | |
}, | |
{ | |
"name": "Mississippi", | |
"code": "MS" | |
}, | |
{ | |
"name": "Missouri", | |
"code": "MO" | |
}, | |
{ | |
"name": "Montana", | |
"code": "MT" | |
}, | |
{ | |
"name": "Nebraska", | |
"code": "NE" | |
}, | |
{ | |
"name": "Nevada", | |
"code": "NV" | |
}, | |
{ | |
"name": "New Hampshire", | |
"code": "NH" | |
}, | |
{ | |
"name": "New Jersey", | |
"code": "NJ" | |
}, | |
{ | |
"name": "New Mexico", | |
"code": "NM" | |
}, | |
{ | |
"name": "New York", | |
"code": "NY" | |
}, | |
{ | |
"name": "North Carolina", | |
"code": "NC" | |
}, | |
{ | |
"name": "North Dakota", | |
"code": "ND" | |
}, | |
{ | |
"name": "Ohio", | |
"code": "OH" | |
}, | |
{ | |
"name": "Oklahoma", | |
"code": "OK" | |
}, | |
{ | |
"name": "Oregon", | |
"code": "OR" | |
}, | |
{ | |
"name": "Pennsylvania", | |
"code": "PA" | |
}, | |
{ | |
"name": "Rhode Island", | |
"code": "RI" | |
}, | |
{ | |
"name": "South Carolina", | |
"code": "SC" | |
}, | |
{ | |
"name": "South Dakota", | |
"code": "SD" | |
}, | |
{ | |
"name": "Tennessee", | |
"code": "TN" | |
}, | |
{ | |
"name": "Texas", | |
"code": "TX" | |
}, | |
{ | |
"name": "Utah", | |
"code": "UT" | |
}, | |
{ | |
"name": "Vermont", | |
"code": "VT" | |
}, | |
{ | |
"name": "Virginia", | |
"code": "VA" | |
}, | |
{ | |
"name": "Washington", | |
"code": "WA" | |
}, | |
{ | |
"name": "West Virginia", | |
"code": "WV" | |
}, | |
{ | |
"name": "Wisconsin", | |
"code": "WI" | |
}, | |
{ | |
"name": "Wyoming", | |
"code": "WY" | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AL": "Alabama", | |
"AK": "Alaska", | |
"AZ": "Arizona", | |
"AR": "Arkansas", | |
"CA": "California", | |
"CO": "Colorado", | |
"CT": "Connecticut", | |
"DE": "Delaware", | |
"FL": "Florida", | |
"GA": "Georgia", | |
"HI": "Hawaii", | |
"ID": "Idaho", | |
"IL": "Illinois", | |
"IN": "Indiana", | |
"IA": "Iowa", | |
"KS": "Kansas", | |
"KY": "Kentucky", | |
"LA": "Louisiana", | |
"ME": "Maine", | |
"MD": "Maryland", | |
"MA": "Massachusetts", | |
"MI": "Michigan", | |
"MN": "Minnesota", | |
"MS": "Mississippi", | |
"MO": "Missouri", | |
"MT": "Montana", | |
"NE": "Nebraska", | |
"NV": "Nevada", | |
"NH": "New Hampshire", | |
"NJ": "New Jersey", | |
"NM": "New Mexico", | |
"NY": "New York", | |
"NC": "North Carolina", | |
"ND": "North Dakota", | |
"OH": "Ohio", | |
"OK": "Oklahoma", | |
"OR": "Oregon", | |
"PA": "Pennsylvania", | |
"RI": "Rhode Island", | |
"SC": "South Carolina", | |
"SD": "South Dakota", | |
"TN": "Tennessee", | |
"TX": "Texas", | |
"UT": "Utah", | |
"VT": "Vermont", | |
"VA": "Virginia", | |
"WA": "Washington", | |
"WV": "West Virginia", | |
"WI": "Wisconsin", | |
"WY": "Wyoming" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment