lightswitch05 / table-to-json

Serializes HTML tables into JSON objects.
http://lightswitch05.github.io/table-to-json/
MIT License
756 stars 172 forks source link

Values from COLSPAN duplicated #23

Closed bdolnik closed 4 years ago

bdolnik commented 8 years ago

Hi, thanks for this code... finding it very useful. One thing we are running into is when using a table with colspan, the value is duplicated in the json output.

So for instance I have a table with 2 rows and 3 columns, and a COLSPAN. The values in the table would be row1: c1, c2, c3 | row2: c4, c5 (COLSPAN on columns 1 and 2 of second row).

The JSON output looks like this...

c1,c2,c3 c4,c4,c5

Any way around this?

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/27035195-values-from-colspan-duplicated?utm_campaign=plugin&utm_content=tracker%2F228299&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F228299&utm_medium=issues&utm_source=github).
lightswitch05 commented 8 years ago

You should have a look at the rewrite branch. It is a complete re-write and has better colspan and rowspan handling. The only reason it hasn't been released yet is because I was hoping to add more features in terms of events and hooks - but at this rate I should probably go ahead and release it.

lightswitch05 commented 8 years ago

Actually - I think I misunderstood your request. After re-reading your question, it looks like the code is working how it is supposed to - but that you want to turn off colspan support.

H1 H2 H3
R1C1 R1C2 R1C3
R2C1 R2C1 (spanned) R2C3

How it currently works

[
    {
        "H1": "R1C1",
        "H2": "R1C2",
        "H3": "R1C3"
    }, {
        "H1": "R2C1",
        "H2": "R2C1",
        "H3": "R2C3"
    }
]

How you would like it to work?

[
    {
        "H1": "R1C1",
        "H2": "R1C2",
        "H3": "R1C3"
    }, {
        "H1": "R2C1",
        "H2": null,
        "H3": "R2C3"
    }
]

Am I understanding this correctly?

bdolnik commented 8 years ago

Yes that's correct, a null value in there would seem to make more sense.

rattozone commented 7 years ago

Is there any solution with olspan and rowspan support?

lightswitch05 commented 7 years ago

@rattozone yes, colspan and rowspan are supported

lightswitch05 commented 4 years ago

closing do to inactivity