Live data from Hacker News

Table-to-JSON

lightswitch05.github.io

31–33 of 33 posts

Re: Table-to-JSON

#31
post #20

Can we go the other way? JSON to Table? That would make this a really useful library for saving table states.

I've had multiple people ask me about that. There are already tools out there that do it, so I didn't really have any motivation to make it

Re: Table-to-JSON

#33
post #7
post #5

It's a nice start to something that looks pretty useful. There are some things to consider though: What if you have headings as the first column in each row? What if you have headings in the first column, and the first row? Also, what is the use case for data overrides? In my opinion, it completely defeats the purpose when your intention is to take the contents of the table.

The code does not try to be clever: var getHeadings = function(table) { var firstRow = table.find("tr:first").first(); return notNull(opts.headings) ? opts.headings : rowValues(firstRow); }; The code is also going to fall down if you have things like wide/high cells. But HTML tables are so flexible and so routinely abused, I guess the problem is too hard to be solved robustly with any generality.

Your more than welcome to submit a pull request for any new features you'd like me to add/support. As for my code. I wrote it in a day for a specific page. After seeing people with similar needs on stack-overflow I decided to clean it up a bit and make it a plugin, never really spent a whole lot of time on it. I think my filterable plugin deserves more attention this this one does (http://lightswitch05.github.io/filterable)
Post reply on HN