Skip to content

Commit e3a347f

Browse files
committed
bug fixed but everything is string now
1 parent 6f6b992 commit e3a347f

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "jsonfromtable",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "Generate json output from html tables",
55
"main": "index.js",
66
"repository": {

utils/tojson.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,7 @@ const toJson = ($, tableSelector, _header) => {
88
}
99

1010
$(`${tableSelector} th`).each((_, el) => {
11-
header.push(
12-
$(el)
13-
.text()
14-
.trim()
15-
)
11+
header.push($(el).text().trim())
1612
})
1713

1814
if (_header) {
@@ -29,17 +25,8 @@ const toJson = ($, tableSelector, _header) => {
2925
j = 0
3026

3127
$(`${tableSelector} td`).each((_, el) => {
32-
let val = $(el)
33-
.text()
34-
.trim()
35-
36-
if (!isNaN(parseFloat(val))) {
37-
val = parseFloat(val)
38-
}
28+
let val = $(el).text().trim()
3929

40-
if (val == '') {
41-
val = 0
42-
}
4330
d[`${header[j]}`] = val
4431

4532
if (j == header.length - 1) {

0 commit comments

Comments
 (0)