# Serialization

## Introduction

For some of our datatypes we provide a way to save them in and load them from JSON format. This is still experimental and it will take some time until all corners of OSCAR are covered by this effort. The goal of this effort is threefold:

• Avoid recomputation by providing an easy way to store data.
• Increase portability by giving a convenient possibility to transport data.
• Increase overall software quality by testing against existing data and tracking errors through data computed by different versions.
saveFunction
save(io::IO, obj::Any)
save(filename::String, obj::Any)

Save an object T to the given io stream respectively to the file filename.

See load.

Examples

julia> save("/tmp/fourtitwo.json", 42);

42
source
loadFunction
load(io::IO; parent::Any = nothing, type::Any = nothing)
load(filename::String; parent::Any = nothing, type::Any = nothing)

Load the object stored in the given io stream respectively in the file filename.

If parent is specified, then the root object of the loaded data either will have this as its parent, or it is a container such as Vector and Tuple, then the parent of the entries will be set to parent.

If a type T is given then attempt to load the root object of the data being loaded with this type; if this fails, an error is thrown.

See save.

Examples

julia> save("/tmp/fourtitwo.json", 42);

42

42

julia> R, x = QQ["x"]
(Univariate Polynomial Ring in x over Rational Field, x)

julia> p = x^2 - x + 1
x^2 - x + 1

julia> save("/tmp/p.json", p)

x^2 - x + 1

julia> parent(p_loaded) === R
true

julia> save("/tmp/p_v.json", [p, p])

2-element Vector{fmpq_poly}:
x^2 - x + 1
x^2 - x + 1

true
source

## Objects that can be serialized

In this section we will list objects that may be (de-)serialized. This list may be incomplete.

Many low level objects may be stored and these in turn allow serializing higher level objects. Such low level objects are various types of matrices, vectors and sets.

### Combinatorics

Graph
SimplicialComplex

### Commutative Algebra

Ideal
Polynomial
PolynomialRing

### Polyhedral Geometry

Cone
LinearProgram
PolyhedralFan
PolyhedralComplex
Polyhedron
SubdivisionOfPoints

### Toric Geometry

NormalToricVariety
ToricDivisor

### Tropical Geometry

TropicalCurve
TropicalHypersurface