class IOStreams::Tabular::Parser::Json
For parsing a single line of JSON at a time
Public Instance Methods
parse(row)
click to toggle source
# File lib/io_streams/tabular/parser/json.rb, line 7 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) JSON.parse(row) end
render(row, header)
click to toggle source
Return the supplied array as a single line JSON string.
# File lib/io_streams/tabular/parser/json.rb, line 16 def render(row, header) hash = header.to_hash(row) hash.to_json end
requires_header?()
click to toggle source
# File lib/io_streams/tabular/parser/json.rb, line 21 def requires_header? false end