You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+12-10Lines changed: 12 additions & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,7 +17,7 @@ npm install jsonfromtable
17
17
```js
18
18
constjsonfromtable=require('jsonfromtable')
19
19
20
-
jsonfromtable(options, headers).then(data=> {
20
+
jsonfromtable(options, headers).then((data)=> {
21
21
console.log(data)
22
22
})
23
23
```
@@ -34,7 +34,7 @@ If you want the output from a url then you need to pass `url` option. The url sh
34
34
35
35
```js
36
36
options = {
37
-
url:'https://www.example.com'
37
+
url:'https://www.example.com',
38
38
}
39
39
```
40
40
@@ -44,7 +44,7 @@ If you want the output from a html then you need to pass `html` option. The html
44
44
45
45
```js
46
46
options = {
47
-
html:'<table>....</table>'
47
+
html:'<table>....</table>',
48
48
}
49
49
```
50
50
@@ -55,7 +55,7 @@ If you want the json output then you can pass `format` option.
55
55
```js
56
56
options = {
57
57
url:'https://www.example.com',
58
-
format:'json'// default => jsobject
58
+
format:'json',// default => jsobject
59
59
}
60
60
```
61
61
@@ -65,23 +65,25 @@ If the page has more than one table, then you can pass id of the table as `selec
65
65
66
66
```js
67
67
options = {
68
-
url:'https:///www.example.com',
69
-
selector:'#table_example'// default => table
68
+
url:'https://www.example.com',
69
+
selector:'#table_example',// default => table
70
70
}
71
71
```
72
72
73
73
<br />
74
74
75
75
## Headers
76
76
77
-
If the table doesn't have `<th>` tags then you need to pass headers on your own. Make sure no of items in headers in equal to the no of columns of table.
77
+
The first row from table is taken a key. You can also pass your ownheaders
78
78
79
79
```js
80
-
headers = ['header1', 'header2', 'header3']
80
+
options = {
81
+
url:'https://www.example.com',
82
+
selector:'#table_example', // default => table
83
+
headers: ['header1', 'header2', 'header3'],
84
+
}
81
85
```
82
86
83
-
If your table has `<th>` tags as headers but you want to pass your own header then also it will work and it is not necessary to pass all the headers equal to no of columns.
0 commit comments