Skip to content

Commit f9812b4

Browse files
committed
[FileFormats.MOF] replace JSON3 by JSON.jl
1 parent c755a67 commit f9812b4

5 files changed

Lines changed: 13 additions & 9 deletions

File tree

Project.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"
77
CodecBzip2 = "523fee87-0ab8-5b00-afb7-3ecf72e48cfd"
88
CodecZlib = "944b1d66-785c-5afd-91f1-9de20f533193"
99
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
10-
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
10+
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
11+
JSONSchema = "7d188eb4-7ad8-530c-ae41-71a32a6d4692"
1112
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1213
MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
1314
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
@@ -23,7 +24,7 @@ BenchmarkTools = "1"
2324
CodecBzip2 = "0.6, 0.7, 0.8"
2425
CodecZlib = "0.6, 0.7"
2526
ForwardDiff = "0.10, 1"
26-
JSON3 = "1"
27+
JSON = "1.4.0"
2728
JSONSchema = "1"
2829
LinearAlgebra = "<0.0.1, 1.6"
2930
MutableArithmetics = "1"

src/FileFormats/MOF/MOF.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
module MOF
88

99
import ..FileFormats
10-
import JSON3
10+
import JSON
1111
import MathOptInterface as MOI
1212

1313
"""

src/FileFormats/MOF/read.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ function Base.read!(io::IO, model::Model)
1313
if !MOI.is_empty(model)
1414
error("Cannot read model from file as destination model is not empty.")
1515
end
16-
object = JSON3.read(io, Dict{String,Any})
16+
object = JSON.parse(io; dicttype = Dict{String,Any})
1717
file_version = _parse_mof_version(object["version"]::Dict{String,Any})
1818
if !(file_version in _SUPPORTED_VERSIONS)
1919
version = _SUPPORTED_VERSIONS[1]

src/FileFormats/MOF/write.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ function Base.write(io::IO, model::Model)
3333
if has_scalar_nonlinear
3434
object = (; has_scalar_nonlinear = true, object...)
3535
end
36-
JSON3.write(io, object)
36+
Base.write(io, JSON.json(object))
3737
return
3838
end
3939

test/FileFormats/MOF/MOF.jl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module TestMOF
88

99
using Test
1010

11-
import JSON3
11+
import JSON
1212
import JSONSchema
1313
import MathOptInterface as MOI
1414

@@ -17,7 +17,10 @@ const MOF = MOI.FileFormats.MOF
1717
const TEST_MOF_FILE = "test.mof.json"
1818

1919
const SCHEMA = JSONSchema.Schema(
20-
JSON3.read(read(MOI.FileFormats.MOF.SCHEMA_PATH, String), Dict{String,Any}),
20+
JSON.parse(
21+
read(MOI.FileFormats.MOF.SCHEMA_PATH, String);
22+
dicttype = Dict{String,Any},
23+
),
2124
)
2225

2326
function runtests()
@@ -40,7 +43,7 @@ function _validate(filename::String)
4043
"r",
4144
MOI.FileFormats.AutomaticCompression(),
4245
) do io
43-
object = JSON3.read(io, Dict{String,Any})
46+
object = JSON.parse(io, Dict{String,Any})
4447
ret = JSONSchema.validate(SCHEMA, object)
4548
if ret !== nothing
4649
error(
@@ -1565,7 +1568,7 @@ function test_use_nlp_block()
15651568
io = IOBuffer()
15661569
write(io, model)
15671570
seekstart(io)
1568-
object = JSON3.read(io, Dict{String,Any})
1571+
object = JSON.parse(io, Dict{String,Any})
15691572
@test object["has_scalar_nonlinear"] == true
15701573
@test JSONSchema.validate(SCHEMA, object) === nothing
15711574
# Test (; use_nlp_block = nothing)

0 commit comments

Comments
 (0)