Skip to content

Commit 2f55a13

Browse files
committed
Drop JSON2 dependancy
1 parent 5367d43 commit 2f55a13

File tree

5 files changed

+10
-26
lines changed

5 files changed

+10
-26
lines changed

Project.toml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
99
Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f"
1010
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
1111
Graphs = "86223c79-3864-5bf0-83f7-82e725a168b6"
12-
JSON2 = "2535ab7d-5cd8-5a07-80ac-9b1792aadce3"
1312
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
1413
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1514
ManifoldsBase = "3362f125-f0bb-47a3-aa74-596ffd7ef2fb"
@@ -32,7 +31,6 @@ Distributions = "0.23, 0.24, 0.25"
3231
DocStringExtensions = "0.8, 0.9"
3332
GraphPlot = "0.5.0"
3433
Graphs = "1.4"
35-
JSON2 = "0.3"
3634
JSON3 = "1"
3735
ManifoldsBase = "0.12, 0.13, 0.14"
3836
OrderedCollections = "1.4"

docs/src/variable_factor_serialization.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ upFactor = unpackFactor(dfg, pFactor, IncrementalInference)
3636
# to make it useable. Please add an issue if this poses a problem or causes issues.
3737
```
3838

39-
As a more complex example, we can use JSON2 to stringify the data and write it to a folder of files as FileDFG does:
39+
As a more complex example, we can use JSON3 to stringify the data and write it to a folder of files as FileDFG does:
4040

4141
```julia
4242
using DistributedFactorGraphs
@@ -50,19 +50,19 @@ x0 = addVariable!(dfg, :x0, Pose2)
5050
# Add at a fixed location PriorPose2 to pin :x0 to a starting location (10,10, pi/4)
5151
prior = addFactor!(dfg, [:x0], PriorPose2( MvNormal([10; 10; 1.0/8.0], Matrix(Diagonal([0.1;0.1;0.05].^2))) ) )
5252

53-
# Slightly fancier example: We can use JSON2, we can serialize to a string
53+
# Slightly fancier example: We can use JSON3, we can serialize to a string
5454
varFolder = "/tmp"
5555
for v in getVariables(dfg)
5656
vPacked = packVariable(dfg, v)
5757
io = open("$varFolder/$(v.label).json", "w")
58-
JSON2.write(io, vPacked)
58+
JSON3.write(io, vPacked)
5959
close(io)
6060
end
6161
# Factors
6262
for f in getFactors(dfg)
6363
fPacked = packFactor(dfg, f)
6464
io = open("$folder/factors/$(f.label).json", "w")
65-
JSON2.write(io, fPacked)
65+
JSON3.write(io, fPacked)
6666
close(io)
6767
end
6868
```

src/DistributedFactorGraphs.jl

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ using Dates
2222
using TimeZones
2323
using Distributions
2424
using Reexport
25-
import JSON2 # only for unpacking factorData via NamedTuples, TODO drop dependency
2625
using JSON3
2726
using StructTypes
2827
using LinearAlgebra

src/services/Serialization.jl

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ function packFactor(dfg::AbstractDFG, f::DFGFactor)
234234
return props
235235
end
236236

237-
function reconstFactorData() end
237+
function reconstFactorData end
238238

239239
function decodePackedType(dfg::AbstractDFG, varOrder::AbstractVector{Symbol}, ::Type{T}, packeddata::GenericFunctionNodeData{PT}) where {T<:FactorOperationalMemory, PT}
240240
#
@@ -248,24 +248,11 @@ function decodePackedType(dfg::AbstractDFG, varOrder::AbstractVector{Symbol}, ::
248248
return factordata
249249
end
250250

251-
# TODO: REFACTOR THIS AS A JSON3 STRUCT DESERIALIZER.
252251
function fncStringToData(packtype::Type{<:AbstractPackedFactor}, data::String)
253252

254-
# Convert string to Named Tuples for kwargs
255-
# packed_ = JSON3.read(data, GenericFunctionNodeData{packtype})
256-
fncData = JSON3.read(data) #, NamedTuple) # Dict{String,Any})
257-
258-
259-
# data isa AbstractString ? JSON2.read(data) : data
260-
# JSON3.generate_type(packed.fnc)
261-
# JSON3.generate_type(fncData["fnc"])
262-
263-
# TODO use kwdef constructors instead,
264-
# @info "user factor" fncData["fnc"]
265-
restring = JSON3.write(fncData["fnc"])
266-
# @show restring
267-
# packT = JSON3.read(restring, packtype)
268-
packT = packtype(;JSON2.read(restring)...)
253+
# Read string as JSON object to use as kwargs
254+
fncData = JSON3.read(data)
255+
packT = packtype(;fncData.fnc...)
269256

270257
packed = GenericFunctionNodeData{packtype}(
271258
fncData["eliminated"],
@@ -281,7 +268,7 @@ function fncStringToData(packtype::Type{<:AbstractPackedFactor}, data::String)
281268
)
282269
return packed
283270
end
284-
fncStringToData(packtype::Type{<:AbstractPackedFactor}, data::NamedTuple) = error("Who is calling deserialize factor with NamedTuple, likely JSON2 somewhere")
271+
fncStringToData(packtype::Type{<:AbstractPackedFactor}, data::NamedTuple) = error("Who is calling deserialize factor with NamedTuple, likely JSON3 somewhere")
285272

286273
fncStringToData(::Type{T}, data::PackedFunctionNodeData{T}) where {T <: AbstractPackedFactor} = data
287274
function fncStringToData(fncType::String, data::PackedFunctionNodeData{T}) where {T <: AbstractPackedFactor}

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ end
5858
end
5959

6060

61-
if get(ENV, "IIF_TEST", "") == "true"
61+
if get(ENV, "IIF_TEST", "true") == "true"
6262

6363
# Switch to our upstream test branch.
6464
Pkg.add(PackageSpec(name="IncrementalInference", rev="upstream/dfg_integration_test"))

0 commit comments

Comments
 (0)