Skip to content

Instantly share code, notes, and snippets.

@stevenkaspar
Created July 15, 2022 20:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevenkaspar/7f06b8b544139f681332bea835690c1f to your computer and use it in GitHub Desktop.
Save stevenkaspar/7f06b8b544139f681332bea835690c1f to your computer and use it in GitHub Desktop.
HTML Table to JSON
(() => {
const table = document.querySelector('#COVERAGECLASSCODES')
const rows = table.querySelectorAll('tr')
const data_rows = []
rows.forEach((row) => {
const data_row = []
const cells = row.querySelectorAll('td')
cells.forEach((cell) => data_row.push(cell.innerText.trim()))
const object = {
code: data_row[0],
system: 'http://terminology.hl7.org/CodeSystem/coverage-class',
display: data_row[1],
description: data_row[2],
version: '4.3.0',
}
data_rows.push(object)
})
console.log(JSON.stringify(data_rows, null, ' '))
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment