Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zenizh/jsonl
Module for handling JSONL (JSON Lines).
https://github.com/zenizh/jsonl
Last synced: about 1 month ago
JSON representation
Module for handling JSONL (JSON Lines).
- Host: GitHub
- URL: https://github.com/zenizh/jsonl
- Owner: zenizh
- License: mit
- Created: 2017-03-15T13:34:34.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2017-03-16T09:14:40.000Z (almost 8 years ago)
- Last Synced: 2024-10-31T14:19:45.833Z (about 2 months ago)
- Language: Ruby
- Homepage: https://rubygems.org/gems/jsonl
- Size: 12.7 KB
- Stars: 16
- Watchers: 2
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# JSONL
[![Gem Version](https://badge.fury.io/rb/jsonl.svg)](https://badge.fury.io/rb/jsonl)
[![Build Status](https://travis-ci.org/kami-zh/jsonl.svg?branch=master)](https://travis-ci.org/kami-zh/jsonl)JSONL is just a module for handling [JSONL](http://jsonlines.org) (JSON Lines) parsing with JSON module.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'jsonl'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install jsonl
## Usage
To parse JSONL text, just pass the source to `JSONL.parse`, which transfers the processing to `JSON.parse`.
`source.jsonl`:
```json
{"name": "Gilbert", "wins": [["straight", "7♣"], ["one pair", "10♥"]]}
{"name": "Alexa", "wins": [["two pair", "4♠"], ["two pair", "9♠"]]}
{"name": "May", "wins": []}
{"name": "Deloise", "wins": [["three of a kind", "5♣"]]}
``````ruby
require 'jsonl'source = File.read('source.jsonl')
parsed = JSONL.parse(source)
parsed.class #=> Array
parsed.count #=> 4
parsed[0] #=> {"name"=>"Gilbert", "wins"=>[["straight", "7♣"], ["one pair", "10♥"]]}
```## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/kami-zh/jsonl.
## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).