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

change textExtractor to extractor to support object as return value #37

Closed koshuang closed 7 years ago

koshuang commented 7 years ago

With extract method, we can return a nested JSON object. e.g.

$('table').tableToJSON({
  extractor : {
    0 : function(cellIndex, $cell) {
      return {
        name: $cell.find('em').text(),
        avatar: $cell.find('img').attr('src')
      };
    },
    1 : function(cellIndex, $cell) {
      return $cell.find('span').text();
    }
  }
});
koshuang commented 7 years ago

@lightswitch05 got it, I will update the PR soon, thanks for your response. :)

koshuang commented 7 years ago

@lightswitch05 I've update the the PR, could you review again? thanks!

lightswitch05 commented 7 years ago

Thanks for your contribution!

lightswitch05 commented 7 years ago

Included in 0.12.0

koshuang commented 7 years ago

thanks @lightswitch05 , would you mind pushing 0.12.0 to npm?

lightswitch05 commented 7 years ago

@koshuang that totally slipped my mind. Its published now, sorry about the wait!

koshuang commented 7 years ago

@lightswitch05 great, thanks :)