def format_data(data, json = false)
      if json
        JSON.generate(data)
      else
        data.map do |category, cat_data|
          # Capitalize each word in the category symbol.
          # e.g. :liked_tracks becomes 'Liked Tracks'
          title = category.to_s.split('_').map(&:capitalize).join(' ')

          output = if cat_data.empty?
                     "  ** No Data **\n"
                   else
                     case category
                     when /liked_tracks/
                       formatter.tracks(cat_data)
                     when /liked_artists|liked_stations/
                       formatter.sort_list(cat_data)
                     when :liked_albums
                       formatter.albums(cat_data)
                     when /following|followers/
                       formatter.followx(cat_data)
                     end
                   end

          "#{title}:\n#{output}"
        end.join
      end
    end
def format_data(data, json = false)
      if json
        JSON.generate(data)
      else
        data.map do |category, cat_data|
          # Capitalize each word in the category symbol.
          # e.g. :liked_tracks becomes 'Liked Tracks'
          title = category.to_s.split('_').map(&:capitalize).join(' ')

          output = if cat_data.empty?
                     "  ** No Data **\n"
                   else
                     case category
                     when /liked_tracks/
                       formatter.tracks(cat_data)
                     when /liked_artists|liked_stations/
                       formatter.sort_list(cat_data)
                     when :liked_albums
                       formatter.albums(cat_data)
                     when /following|followers/
                       formatter.followx(cat_data)
                     end
                   end

          "#{title}:\n#{output}"
        end.join
      end
    end
Formats data as a string list or JSON.
 @param data [Hash]
 @param json [Boolean]
 @return [String]