Method: JSONL.parse

Defined in:
lib/jsonl.rb

.parse(source, opts = {}) ⇒ Object

Parse JSONL string and return as an array.

Attributes

  • source - a string formatted as JSONL

  • opts - options passes to ‘JSON.parse`

Examples

source = File.read('source.jsonl')
parsed = JSONL.parse(source)


43
44
45
46
47
48
49
# File 'lib/jsonl.rb', line 43

def parse(source, opts = {})
  parsed = []
  source.each_line do |line|
    parsed << JSON.parse(line, opts)
  end
  parsed
end