File tree 4 files changed +78
-3
lines changed
4 files changed +78
-3
lines changed Original file line number Diff line number Diff line change 1
1
name = " JSON3"
2
2
uuid = " 0f8b85d8-7281-11e9-16c2-39a750bddbf1"
3
3
authors = [
" Jacob Quinn <[email protected] >" ]
4
- version = " 1.13.2 "
4
+ version = " 1.14.0 "
5
5
6
6
[deps ]
7
7
Dates = " ade2ca70-3891-5945-98fb-dc099432e06a"
@@ -12,13 +12,22 @@ StructTypes = "856f2bd8-1eba-4b0a-8007-ebc267875bd4"
12
12
UUIDs = " cf7118a7-6976-5b1a-9a39-7adc72f591a4"
13
13
14
14
[compat ]
15
+ ArrowTypes = " 2.2"
15
16
Parsers = " 0.3, 1, 2"
17
+ PrecompileTools = " 1"
16
18
StructTypes = " 1.10"
17
19
julia = " 1.6"
18
- PrecompileTools = " 1"
20
+
21
+ [extensions ]
22
+ JSON3ArrowExt = [" ArrowTypes" ]
19
23
20
24
[extras ]
25
+ Arrow = " 69666777-d1a9-59fb-9406-91d4454c9d45"
26
+ ArrowTypes = " 31f734f8-188a-4ce0-8406-c8a06bd891cd"
21
27
Test = " 8dfed614-e22c-5e08-85e1-65c5234f0b40"
22
28
23
29
[targets ]
24
- test = [" Test" ]
30
+ test = [" Arrow" , " Test" ]
31
+
32
+ [weakdeps ]
33
+ ArrowTypes = " 31f734f8-188a-4ce0-8406-c8a06bd891cd"
Original file line number Diff line number Diff line change
1
+ module JSON3ArrowExt
2
+
3
+ using JSON3
4
+ using ArrowTypes
5
+
6
+ const JSON3_ARROW_NAME = Symbol (" JuliaLang.JSON3.Object" )
7
+
8
+ # It might looks strange to have this as a StructKind when JSON objects are
9
+ # very dict-like, but the valtype is Any, which Arrow.jl really not like
10
+ # and even if we add a
11
+ # toarrow(d::JSON3.Object) d = Dict{String, Union{typeof.(values(d))...}
12
+ # that does not seem to solve the problem.
13
+ ArrowTypes. ArrowKind (:: Type{<:JSON3.Object} ) = ArrowTypes. StructKind ()
14
+ ArrowTypes. arrowname (:: Type{<:JSON3.Object} ) = JSON3_ARROW_NAME
15
+ ArrowTypes. JuliaType (:: Val{JSON3_ARROW_NAME} ) = JSON3. Object
16
+
17
+ end # module
Original file line number Diff line number Diff line change
1
+ using Arrow
2
+
3
+ obj1 = JSON3. read ("""
4
+ {
5
+ "int": 1,
6
+ "float": 2.1
7
+ }
8
+ """ )
9
+
10
+ obj2 = JSON3. read ("""
11
+ {
12
+ "int": 1,
13
+ "float": 2.1,
14
+ "bool1": true,
15
+ "bool2": false,
16
+ "none": null,
17
+ "str": "\\ "hey there sailor\\ "",
18
+ "arr": [null, 1, "hey"],
19
+ "arr2": [1.2, 3.4, 5.6]
20
+ }
21
+ """ )
22
+
23
+ obj3 = JSON3. read ("""
24
+ {
25
+ "int": 1,
26
+ "float": 2.1,
27
+ "bool1": true,
28
+ "bool2": false,
29
+ "none": null,
30
+ "str": "\\ "hey there sailor\\ "",
31
+ "obj": {
32
+ "a": 1,
33
+ "b": null,
34
+ "c": [null, 1, "hey"],
35
+ "d": [1.2, 3.4, 5.6]
36
+ },
37
+ "arr": [null, 1, "hey"],
38
+ "arr2": [1.2, 3.4, 5.6]
39
+ }
40
+ """ )
41
+
42
+ tbl = (; json= [obj1, obj2, obj3])
43
+
44
+ arrow = Arrow. Table (Arrow. tobuffer (tbl))
45
+ @test tbl. json == arrow. json
Original file line number Diff line number Diff line change @@ -1103,4 +1103,8 @@ y = Vector{UndefGuy}(undef, 2)
1103
1103
y[1 ] = x
1104
1104
@test JSON3. write (y) == " [{\" id\" :10},null]"
1105
1105
1106
+ @static if isdefined (Base, :get_extension )
1107
+ @testset " Arrow" include (" arrow.jl" )
1108
+ end
1109
+
1106
1110
end # @testset "JSON3"
You can’t perform that action at this time.
0 commit comments