Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
GAP = "c863536a-3901-11e9-33e7-d5cd0df7b904"
Hecke = "3e1990a7-5d81-5526-99ce-9ba3ff248f21"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
LazyArtifacts = "4af54fe1-eca0-43a8-85a7-787d91b784e3"
Markdown = "d6f4376e-aef5-505a-96c1-9c027394607a"
Mongoc = "4fe8b98c-fc19-5c23-8ec2-168ff83495f2"
Expand All @@ -38,7 +37,6 @@ Distributed = "1.6"
GAP = "0.16.0"
Hecke = "0.38.5"
JSON = "1.0.1"
JSON3 = "1.13.2"
LazyArtifacts = "1.6"
Markdown = "1.6"
Mongoc = "0.9.2, 0.10"
Expand Down
2 changes: 1 addition & 1 deletion docs/src/DeveloperDocumentation/serialization.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ With the corresponding loading function similar to this.
```julia
function load_object(s::DeserializerState, ::Type{<:NewType})
(obj1, obj2, obj3_4) = load_array_node(s) do (i, entry)
if entry isa JSON3.Object
if entry isa JSON.Object
obj3 = load_object(s, Obj3Type, :key1)
obj4 = load_object(s, Obj3Type, :key2)
return OtherType(obj3, obj4)
Expand Down
10 changes: 5 additions & 5 deletions src/Serialization/main.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ end
# FIXME: this function is exported but undocumented
function read_metadata(filename::String)
open(filename) do io
obj = JSON3.read(io)
obj = JSON.parse(io; dicttype=Dict{Symbol, Any}) # TODO: check if JSON.Object works here
println(JSON.json(obj[:meta], 2))
end
end
Expand Down Expand Up @@ -373,7 +373,7 @@ function load_type_params(s::DeserializerState, T::Type)
end
if haskey(s, :params)
load_node(s, :params) do obj
if obj isa JSON3.Array || obj isa Vector
if obj isa Vector
params = load_type_array_params(s)
elseif obj isa String || haskey(s, :params)
U = decode_type(s)
Expand All @@ -387,7 +387,7 @@ function load_type_params(s::DeserializerState, T::Type)
params = Dict{Symbol, Any}()
for (k, _) in obj
params[k] = load_node(s, k) do obj
if obj isa JSON3.Array || obj isa Vector
if obj isa Vector
return load_type_array_params(s)
end

Expand Down Expand Up @@ -639,8 +639,8 @@ julia> save("fourtitwo.mrdi", 42; metadata=meta);
julia> read_metadata("fourtitwo.mrdi")
{
"author_orcid": "0000-0000-0000-0042",
"name": "42",
"description": "The meaning of life, the universe and everything"
"description": "The meaning of life, the universe and everything",
"name": "42"
}

julia> load("fourtitwo.mrdi")
Expand Down
6 changes: 2 additions & 4 deletions src/Serialization/serializers.jl
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
using JSON3

################################################################################
# Type Serializers (converting types to strings)
convert_type_to_string(T::DataType) = sprint(show, T; context=:module=>Oscar)
Expand Down Expand Up @@ -200,7 +198,7 @@ mutable struct DeserializerState{T <: OscarSerializer}
# or perhaps Dict{Int,Any} to be resilient against corrupts/malicious files using huge ids
# the values of refs are objects to be deserialized
serializer::T
obj::Union{AbstractDict{Symbol, Any}, Vector, JSON3.Array, BasicTypeUnion}
obj::Union{AbstractDict{Symbol, Any}, Vector, BasicTypeUnion}
key::Union{Symbol, Int, Nothing}
refs::Union{AbstractDict{Symbol, Any}, Nothing}
with_attrs::Bool
Expand Down Expand Up @@ -265,7 +263,7 @@ function serializer_open(
end

function deserializer_open(io::IO, serializer::OscarSerializer, with_attrs::Bool)
obj = JSON3.read(io)
obj = JSON.parse(io; dicttype=JSON.Object{Symbol, Any})
refs = get(obj, :_refs, nothing)

return DeserializerState(serializer, obj, nothing, refs, with_attrs)
Expand Down
Loading