Skip to content

Commit 476851b

Browse files
authored
[FileFormats.MOF] replace JSON3 by JSON.jl (#2918)
1 parent c755a67 commit 476851b

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- version: '1'
3939
os: windows-latest
4040
arch: x64
41-
- version: '1.6'
41+
- version: '1.10'
4242
os: ubuntu-latest
4343
arch: x64
4444
- version: '1'

Project.toml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ 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"
1111
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1212
MutableArithmetics = "d8a4904e-b15c-11e9-3269-09a3773c0cb0"
1313
NaNMath = "77ba4419-2d1f-58cd-9bb1-8ffee604a2e3"
@@ -23,18 +23,18 @@ BenchmarkTools = "1"
2323
CodecBzip2 = "0.6, 0.7, 0.8"
2424
CodecZlib = "0.6, 0.7"
2525
ForwardDiff = "0.10, 1"
26-
JSON3 = "1"
26+
JSON = "1"
2727
JSONSchema = "1"
28-
LinearAlgebra = "<0.0.1, 1.6"
28+
LinearAlgebra = "1"
2929
MutableArithmetics = "1"
3030
NaNMath = "0.3, 1"
3131
OrderedCollections = "1"
3232
PrecompileTools = "1"
33-
Printf = "<0.0.1, 1.6"
34-
SparseArrays = "<0.0.1, 1.6"
33+
Printf = "1"
34+
SparseArrays = "1"
3535
SpecialFunctions = "0.8, 1, 2"
36-
Test = "<0.0.1, 1.6"
37-
julia = "1.6"
36+
Test = "1"
37+
julia = "1.10"
3838

3939
[extras]
4040
JSONSchema = "7d188eb4-7ad8-530c-ae41-71a32a6d4692"

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; dicttype = 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; dicttype = 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)