JSONL is a module for handling JSONL (JSON Lines) parsing.
-
Add the dependency to your
shard.yml
:dependencies: jsonl: github: Sija/jsonl.cr
-
Run
shards install
require "jsonl"
arr = JSONL.parse <<-JSONL
{"foo": "bar"}
[1, 2, 3]
"foo"
JSONL
arr.class # => Array(JSON::Any)
class User
include JSON::Serializable
property id : Int32
property first_name : String
property last_name : String
end
input = <<-JSONL
{"id": 1, "first_name": "John", "last_name": "Doe"}
{"id": 2, "first_name": "Mary", "last_name": "Poppins"}
{"id": 3, "first_name": "Jack", "last_name": "Black"}
JSONL
users = User.from_jsonl(input)
users.class # => Array(User)
# no array allocation here
User.from_jsonl(input) do |user|
user.class # => User
end
- Fork it (https://github.com/Sija/jsonl.cr/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
- Sijawusz Pur Rahnama - creator and maintainer