Project

json2table

0.02
No commit activity in last 3 years
No release in over 3 years
This gem provides functionality to convert a JSON object into HTML table. It can handle nested JSONs. Table class, styles and attributes can be provided.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
2026
 Dependencies
 Project Readme

Introduction

json2table is a ruby library and executable to convert valid JSON objects to HTML tables. json2table is also available as a rubygem for quick installation.

Get json2table

You can get json2table by install gem or cloning git repo.

Download gem

Download gem from rubygems as:

$ gem install json2table

Clone git repository

Clone this repository as:

$ git clone https://github.com/codeexpress/json2table

Usage

As a standalone program

If you've installed the gem, json2table is available as a cli command, which can be used as follwing:

$ cat some.json | json2table # outputs table

In your ruby code as library

Refer to the example/example.rb file for sample implementation

require 'json2table' # if you've installed the gem

#require 'path/to/lib/json2table.rb'# if you've git clone'd the repo

table_options = {
  table_style: "border: 1px solid black; max-width: 600px;",
  table_class: "table table-striped table-hover table-condensed table-bordered",
  table_attributes: "border=1"
  }
  json = STDIN.read

  json2table =  Json2table::get_html_table(json, table_options)
  puts json2table

Invoke example.rb as:

$ cd example
$ cat input.json | ruby example.rb > output.html