# How to save and read a structure?

**URL:** <https://discourse.julialang.org/t/how-to-save-and-read-a-structure/71031>\
**Category:** General Usage\
**Tags:** question, struct, io\
**Created:** [November 5, 2021, 10:54pm UTC](https://discourse.julialang.org/t/how-to-save-and-read-a-structure/71031 "2021-11-05T22:54:10Z")\
**Posts on this page:** 2\
**Page:** 2

<div class="post-metadata">

**Author:** ![Perrin\_Meyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/perrin_meyer/32/15686_2.png) [@Perrin\_Meyer](https://discourse.julialang.org/u/Perrin_Meyer)\
**Post date:** [November 9, 2021, 1:31am UTC](https://discourse.julialang.org/t/how-to-save-and-read-a-structure/71031/21 "2021-11-09T01:31:23Z")

</div>

BSON.jl is a Julia package for working with the Binary JSON serialisation format. It can be used as a general store for Julia data structures, with the following features:

Lightweight and ubiquitous, with a simple JSON-like data model and clients in many languages.  
Efficient for binary data (eg. arrays of floats).  
Flexible enough to handle anything you throw at it – closures, custom types, circular data structures, etc.  
Backwards compatible, so that if data layout changes old files will still load.

---

<div class="post-metadata">

**Author:** ![albheim](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/albheim/32/34660_2.png) [@albheim](https://discourse.julialang.org/u/albheim)\
**Post date:** [November 10, 2021, 7:58am UTC](https://discourse.julialang.org/t/how-to-save-and-read-a-structure/71031/23 "2021-11-10T07:58:15Z")

</div>

It seems to load fine

```julia
... # Your code to save

julia> load("My_file.jld2")
Dict{String, Any} with 1 entry:
  "CP" => S[S(["3d4f7006", "3d4f7006"], [2.0, 3.0]), S(["3d5ce1ef", "3d5ce1ef"], [7.0, 8.0])]

julia> ans["CP"]
2-element Vector{S}:
 S(["3d4f7006", "3d4f7006"], [2.0, 3.0])
 S(["3d5ce1ef", "3d5ce1ef"], [7.0, 8.0])

```

[Previous page](https://discourse.julialang.org/t/how-to-save-and-read-a-structure/71031.md?page=1)
