lib/snmp_table_viewer/formatter/json.rb
# Output the data. If no headings are provided you'll get an Array or Arrays. If headings are provided you'll get an Array of Hashes.
# @return [String] the JSON data
Output the data. If no headings are provided you'll get an Array or Arrays. If headings are provided you'll get an Array of Hashes.
Output the data . If no headings are provided you ' ll get an Array or Arrays . If headings are provided you ' ll get an Array of Hashes .
def output()
      data = @data
      if @headings.size > 0
        data = data.map{ |row| Hash[row.map.with_index{ |value, index| [@headings[index] || '', value] }] }
      end
      ::JSON.generate(data)
    end
def output ( ) data = @data if @headings . size > 0 data = data . map { | row | Hash [ row . map . with_index { | value , index | [ @headings [ index ] || '' , value ] } ] } end :: JSON . generate ( data ) end
Output the data.
Output the data .
# Convert inner arrays to hashes
the JSON data
the JSON data
String