Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jsoner

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsoner

  • 0.0.4
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

Jsoner

Serialize HTML tables into JSON in Ruby.
Build Status

Installation

Add this line to your application's Gemfile:

gem 'jsoner'

And then execute:

$ bundle

Or install it yourself as:

$ gem install jsoner

Usage

html = <<-eohtml
    <table id='example-table'>
      <thead>
        <tr>
          <th>First Name</th>
          <th>Last Name</th>
          <th>Points</th></tr>
      </thead>
      <tbody>
        <tr>
          <td>Jill</td>
          <td>Smith</td>
          <td>50</td></tr>
        <tr>
          <td>Eve</td>
          <td>Jackson</td>
          <td>94</td></tr>
        <tr>
          <td>John</td>
          <td>Doe</td>
          <td>80</td></tr>
        <tr>
          <td>Adam</td>
          <td>Johnson</td>
          <td>67</td></tr>
      </tbody>
    </table>
  eohtml

# Convert HTML table into Json

json = Jsoner.parse(html)

# output json => 
# 
#   [ {"First Name"=>"Jill", "Last Name"=>"Smith",   "Points"=>"50"},
#     {"First Name"=>"Eve",  "Last Name"=>"Jackson", "Points"=>"94"},
#     {"First Name"=>"John", "Last Name"=>"Doe",     "Points"=>"80"},
#     {"First Name"=>"Adam", "Last Name"=>"Johnson", "Points"=>"67"} ]

Or, Jsoner can parse HTML file including HTML table

require 'open-uri'
# you must have table.html file and assign file path correctly.

table = Jsoner.parse(open('table.html'))

# output json => 
# 
#   [ {"First Name"=>"Jill", "Last Name"=>"Smith",   "Points"=>"50"},
#     {"First Name"=>"Eve",  "Last Name"=>"Jackson", "Points"=>"94"},
#     {"First Name"=>"John", "Last Name"=>"Doe",     "Points"=>"80"},
#     {"First Name"=>"Adam", "Last Name"=>"Johnson", "Points"=>"67"} ]

Or you can open Link

require 'open-uri'

table = Jsoner.parse(open('http://www.w3school.com.cn/tiy/t.asp?f=html_table_header'))

# output json => 
#
# [{"姓名"=>"Bill Gates", "电话"=>"555 77 855"}]

THANKS

table-to-json written by @lightswitch05 in JavaScript.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

FAQs

Package last updated on 01 Aug 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc