lib/io_streams/tabular/parser/json.rb in iostreams-0.15.0 vs lib/io_streams/tabular/parser/json.rb in iostreams-0.16.0
- old
+ new
@@ -3,10 +3,12 @@
class Tabular
module Parser
# For parsing a single line of JSON at a time
class Json < Base
def parse(row)
- raise(Tabular::Errors::TypeMismatch, "Format is :json. Invalid input: #{row.class.name}") unless row.is_a?(String)
+ return row if row.is_a?(::Hash)
+
+ raise(IOStreams::Errors::TypeMismatch, "Format is :json. Invalid input: #{row.class.name}") unless row.is_a?(String)
JSON.parse(row)
end
# Return the supplied array as a single line JSON string.