Add object to existing BSON file?

BSON only reads the first serialized object, and this syntax saves a dict with keys "a" and "b"

a=5
b=6
c=7
 BSON.@save "path/to/file.bson" a b

You can append c with

open("path/to/file.bson", "a") do io
  BSON.@save io c
end

But then you need to issue two reads to get everything back

julia> open("test.bson", "r") do io
            println(BSON.load(io))
            println(BSON.load(io))
       end
Dict{Symbol,Any}(:a => 5,:b => 6)
Dict{Symbol,Any}(:c => 7)

Not very convenient, but maybe useful?

1 Like