JSON Reader

As requested, here is our trusty JSONReader!

class JSONReaderdef initialize(filename)
    @json = String.new
    File.foreach(filename) do |line|
      @json = @json + line
    end
    #binding.pry
  enddef to_hash
    return JSON.parse(@json)
  endend

Usage

reader = JSONReader.new('data.json') # data.json in same dir as this File
model = reader.to_hash

results matching ""

    No results matching ""