Skip to content

Commit 237bc72

Browse files
authored
Merge pull request #2 from sjkelly/sjk/json3
migrate to JSON3
2 parents 83197c2 + 74ef396 commit 237bc72

File tree

4 files changed

+9
-13
lines changed

4 files changed

+9
-13
lines changed

Project.toml

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,9 @@ authors = ["Alexandr Romanenko <[email protected]>"]
44
version = "0.1.0"
55

66
[deps]
7-
JSON2 = "2535ab7d-5cd8-5a07-80ac-9b1792aadce3"
7+
JSON3 = "0f8b85d8-7281-11e9-16c2-39a750bddbf1"
88
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
99

10-
1110
[compat]
12-
JSON2 = "0.3.1"
11+
JSON3 = "1"
1312
julia = "1.2"

src/DashBase.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module DashBase
2-
import JSON2
2+
import JSON3
33
include("components.jl")
44
include("registry.jl")
55
export Component, push_prop!, get_name, get_type, get_namespace,

src/components.jl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,5 @@ Base.propertynames(comp::Component) = collect(get_available_props(comp))
5555

5656
push_prop!(component::Component, prop::Symbol, value) = push!(component.props, prop=>to_dash(value))
5757

58-
JSON2.@format Component begin
59-
name => (exclude = true,)
60-
available_props => (exclude = true,)
61-
wildcard_regex => (exclude = true,)
62-
end
58+
JSON3.StructTypes.StructType(::Type{DashBase.Component}) = JSON3.StructTypes.Struct()
59+
JSON3.StructTypes.excludes(::Type{DashBase.Component}) = (:name, :available_props, :wildcard_regex)

test/components.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using DashBase
2-
using JSON2
2+
using JSON3
33

44
@testset "components creation" begin
55
test_comp = Component("html_div", "Div", "dash_html_components",
@@ -29,9 +29,9 @@ using JSON2
2929
id = 10,
3030
key = 1
3131
)
32-
json = JSON2.write(test_comp)
33-
res = JSON2.read(json)
34-
@test keys(res) == (:type, :namespace, :props)
32+
json = JSON3.write(test_comp)
33+
res = JSON3.read(json)
34+
@test all(keys(res) .== [:type, :namespace, :props])
3535
@test sort(collect(keys(res.props))) == sort([:id, :n_clicks, Symbol("data-id")])
3636
@test res.props.id == 10
3737
@test res.props.n_clicks == 1

0 commit comments

Comments
 (0)