# Serialization/Deserialization what am I doing wrong?

**URL:** <https://discourse.julialang.org/t/serialization-deserialization-what-am-i-doing-wrong/63513>\
**Category:** New to Julia\
**Tags:** serialization\
**Created:** [June 24, 2021, 8:10pm UTC](https://discourse.julialang.org/t/serialization-deserialization-what-am-i-doing-wrong/63513 "2021-06-24T20:10:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![HugoTrentesaux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hugotrentesaux/32/12583_2.png) [@HugoTrentesaux](https://discourse.julialang.org/u/HugoTrentesaux)\
**Post date:** [June 24, 2021, 8:10pm UTC](https://discourse.julialang.org/t/serialization-deserialization-what-am-i-doing-wrong/63513/1 "2021-06-24T20:10:28Z")

</div>

When I enter the following in REPL,

```julia
using Serialization
buffer = IOBuffer()
serialize(buffer, [1,2,3])
deserialize(buffer)

```

I get this error:

```julia
ERROR: EOFError: read end of file
Stacktrace:
 [1] read
   @ ./iobuffer.jl:217 [inlined]
 [2] deserialize
   @ /build/julia/src/julia-1.6.1/usr/share/julia/stdlib/v1.6/Serialization/src/Serialization.jl:782 [inlined]
 [3] deserialize(s::IOBuffer)
   @ Serialization /build/julia/src/julia-1.6.1/usr/share/julia/stdlib/v1.6/Serialization/src/Serialization.jl:769
 [4] top-level scope
   @ REPL[4]:1

```

and the documentation does not help me much: [Serialization · The Julia Language](https://docs.julialang.org/en/v1/stdlib/Serialization/#Serialization.deserialize)

I can test that something has been written:

```julia
julia> serialize(buffer, [1,2,3])
24

julia> String(take!(buffer))
"7JL\r\x04\0\0\0\x15\0\b\xe2\x01\0\0\0\0\0\0\0\x02\0\0\0\0\0\0\0\x03\0\0\0\0\0\0\0"

```

What am I doing wrong?

---

<div class="post-metadata">

**Author:** ![HugoTrentesaux](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hugotrentesaux/32/12583_2.png) [@HugoTrentesaux](https://discourse.julialang.org/u/HugoTrentesaux)\
**Post date:** [June 24, 2021, 8:15pm UTC](https://discourse.julialang.org/t/serialization-deserialization-what-am-i-doing-wrong/63513/2 "2021-06-24T20:15:17Z")

</div>

I’m stupid, that’s what should be done:

```julia
buffer = IOBuffer()
serialize(buffer, [1,2,3])
seek(buffer,0)
deserialize(buffer)

```

which yields:

```julia
3-element Vector{Int64}:
 1
 2
 3

```

Hope it can help someone else…

PS: found the answer in [the tests](https://github.com/JuliaLang/julia/blob/master/stdlib/Serialization/test/runtests.jl)
