一款前端页面table转json工具Table-to-JSON

1.在项目的开发中,我们会遇到需要将前端table转换成json格式,传入后端。手动拼写json是一个耗时耗力的工作,现在有了Table-to-JSON,可以很容易解决问题

官网地址:http://lightswitch05.github.io/table-to-json/

2.配置描述

Options

  • ignoreColumns
    • Array of column indexes to ignore.
    • Type: Array
    • Default: []
  • onlyColumns
    • Array of column indexes to include, all other columns are ignored. This takes presidence over ignoreColumns when provided.
    • This takes presidence over ignoreColumns when both are provided.
    • Type: Array
    • Default: null - all columns
  • ignoreHiddenRows
    • Boolean if hidden rows should be ignored or not.
    • Type: Boolean
    • Default: true
  • headings
    • Array of column headings to use. When supplied, all table rows are treated as values.
    • Type: Array
    • Default: null
  • allowHTML
    • Boolean if HTML tags in table cells should be preserved.
    • Type: Boolean
    • Default: false
  • includeRowId
    • Determines if the id attribute of each <tr> element is included in the JSON.
    • Type: Boolean or String
          If 
      true
          , the ids are included under the header 
      rowId
        .
          If 
      String
          , it is used as the header for the id instead of the default 
      rowId
        .
    • Default: false

Features

  • Automatically finds column headings.
    • Override found column headings by using data-override="overridden column name".
    • Always uses first row as column headings regardless of th and td tags.
    • Define headings using the headings option when a table doesn't have any specified headings.
  • Override cell values column names by using data-override="new value".
  • Ignorable columns.
  • Not confused by nested tables.

 

posted on 2014-12-03 18:04  khh  阅读(591)  评论(0)    收藏  举报

导航