Skip to content

coderosh-zz/jsonfromtable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON FROM TABLE

Converts html tables to JSON and JS objects

NPM

Installation

Install via npm

npm install jsonfromtable

Usage

const jsonfromtable = require('jsonfromtable')

jsonfromtable(options, headers).then((data) => {
  console.log(data)
})

jsonfromtable function takes two arguments options and headers and returns promise.

Check this example in codesandbox.

Options

url

If you want the output from a url then you need to pass url option. The url should be of a webpage which has a table.

options = {
  url: 'https://www.example.com',
}

html

If you want the output from a html then you need to pass html option. The html should contain table tag.

options = {
  html: '<table>....</table>',
}

format

If you want the json output then you can pass format option.

options = {
  url: 'https://www.example.com',
  format: 'json', // default => jsobject
}

selector

If the page has more than one table, then you can pass id of the table as selector.

options = {
  url: 'https://www.example.com',
  selector: '#table_example', // default => table
}

Headers

The first row from table is taken a key. You can also pass your own headers

options = {
  url: 'https://www.example.com',
  selector: '#table_example', // default => table
  headers: ['header1', 'header2', 'header3'],
}

License

MIT

About

Generate json from html tables

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published