You should be able to use BSON, the blessing and the curse of BSON is that it can restore and execute arbitrary code. This makes it unwise to load BSON from untrusted sources and it means that the environment in which the BSON is loaded must have all the functions defined and modules loaded needed to reconstruct the types saved. This worked for me:
using DifferentialEquations
using BSON
spring(du, u, p, t) = -9u
function solve()
du0 = [0.0]
u0 = [2.0]
tspan = (0.0,30.0)
prob = SecondOrderODEProblem(spring,du0,u0,tspan)
solve(prob)
end
sol = solve()
BSON.@save "solution.bson" sol
Then, to restore (in a new Julia session to be sure)
using DifferentialEquations
using BSON
# BSON needs this to reconstruct sol, I got
# ERROR: UndefVarError: LinearAlgebra not defined
# without this
using LinearAlgebra
# The name of the integrated function is part of the type of the ODEProblem,
# and the type of the ODEProblem is part of the type of the ODESolution,
# so the function must be defined, although it does not need to be
# implemented since only its type is used, it is never called.
# The simplest way to do this is probably just to include your "load" function
# in the same module that solves and saves
spring(du, u, p, t) = 0
BSON.@load "solution.bson" sol
sol(5.25)