# De-serialisation conflicts when multiple definitions in the Union

**URL:** <https://discourse.julialang.org/t/de-serialisation-conflicts-when-multiple-definitions-in-the-union/104991>\
**Category:** General Usage\
**Created:** [October 16, 2023, 12:33am UTC](https://discourse.julialang.org/t/de-serialisation-conflicts-when-multiple-definitions-in-the-union/104991 "2023-10-16T00:33:48Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ravitimm](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ravitimm/32/202486_2.png) [@ravitimm](https://discourse.julialang.org/u/ravitimm)\
**Post date:** [October 16, 2023, 12:33am UTC](https://discourse.julialang.org/t/de-serialisation-conflicts-when-multiple-definitions-in-the-union/104991/1 "2023-10-16T00:33:48Z")

</div>

I wonder why the following de-serialisation code does not work.  
In the Geometry struct, if I remove one of the types (Vector{Float64} or Vector{Vector{Float64}), it works.

They appear to be conflicting somehow.  
If I change the definition of ‘coordinates’ to the following, it works.

```julia
Union{Vector{Any},Vector{Vector{Float64}},Nothing}

```

Here is the code:

```julia
import Pkg; Pkg.add("JSON3")
using JSON3

struct Geometry
    # The following commented-out definition works
    # coordinates::Union{Vector{Float64}, Nothing}

    # The following commented-out definition also works
    # coordinates::Union{Vector{Any},Vector{Vector{Float64}},Nothing}

    # But the following definition does not work.
    coordinates::Union{Vector{Float64},Vector{Vector{Float64}},Nothing}
    type::Union{String, Nothing}
end

struct Feature
    feature_id::Union{String, Nothing}
    layer_id::Union{String, Nothing}
    feature_type::Union{String, Nothing}
    type::Union{String, Nothing}
    properties::Union{Dict{String, Any}, Nothing}
    geometry::Union{Geometry, Nothing}
end

text = "{\"type\":\"Feature\", \"geometry\":{\"type\":\"Point\", \"coordinates\":[145.7758519805272, -36.76519129485044]}, \"feature_id\":\"INTERSECTION&&3\", \"layer_id\":\"INTERSECTION\", \"feature_type\":\"POINT\", \"properties\":{\"HexIndexes\":[606831691595513900]}}"

test = JSON3.read(text, Feature)
    @info test.geometry

```
