lib/rbbt/persist.rb in rbbt-util-5.26.21 vs lib/rbbt/persist.rb in rbbt-util-5.26.22

- old
+ new

@@ -122,10 +122,14 @@ when :marshal Open.open(path) do |stream| content = stream.read.unpack("m").first Marshal.load(content) end + when :json + Open.open(path) do |stream| + JSON.parse(stream.read) + end when :yaml Open.open(path) do |stream| YAML.load(stream) end when :float @@ -184,9 +188,11 @@ when :marshal_tsv Misc.sensiblewrite(path, Marshal.dump(content.dup), :lock => lockfile) when :marshal dump = Marshal.dump(content) Misc.sensiblewrite(path, [dump].pack("m"), :lock => lockfile) + when :json + Misc.sensiblewrite(path, JSON.dump(content), :lock => lockfile) when :yaml Misc.sensiblewrite(path, YAML.dump(content), :lock => lockfile) when :float, :integer, :tsv Misc.sensiblewrite(path, content.to_s, :lock => lockfile) else