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