Sha256: ad86652c857091ab3b84142b7ba1762e07e0552767bbafaf4e17b169c1c106d5
Contents?: true
Size: 427 Bytes
Versions: 3
Compression:
Stored size: 427 Bytes
Contents
# frozen_string_literal: true require 'json' class Tabled class JSONParser def self.parse(file_path) file = File.read(file_path) json_entries = ::JSON.parse(file) unless json_entries.is_a?(Array) && json_entries.first.is_a?(Hash) raise ArgumentError, 'Invalid JSON format. Expected an array of objects.' end [json_entries.first.keys, json_entries.map(&:values)] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
tabled-1.2.1 | lib/parsers/json_parser.rb |
tabled-1.2.0 | lib/parsers/json_parser.rb |
tabled-1.1.0 | lib/parsers/json_parser.rb |