Encode/Decode your Julia structures to/from BSON.
- Julia v1.1
using BSONSerializer
struct MyType
str::String
num::Int
end
# this macro will generate
# serialize/deserialize code
@BSONSerializable(MyType)
instance = MyType("hey", 101)
bson = BSONSerializer.serialize(instance)
println(bson)
new_instance = BSONSerializer.deserialize(bson)
@assert new_instance == instance
Generated BSON:
{
"type": "MyType",
"args": {
"str": "hey",
"num": 101
}
}