Do not emit a comma for the final item in JSON output

This avoids producing JSON that is not parsable.
This commit is contained in:
Paul Wise 2021-05-03 20:54:29 +08:00
parent 06e25957b6
commit ba4ca60377
No known key found for this signature in database
GPG Key ID: 3116BA5E9FFA69A3

View File

@ -177,9 +177,10 @@ class WaybackMachineDownloader
files = get_file_list_by_timestamp files = get_file_list_by_timestamp
$stdout = @orig_stdout $stdout = @orig_stdout
puts "[" puts "["
files.each do |file| files[0...-1].each do |file|
puts file.to_json + "," puts file.to_json + ","
end end
puts files[-1].to_json
puts "]" puts "]"
end end