Skip to content

Commit

Permalink
test_json3_parse_jsonlines
Browse files Browse the repository at this point in the history
  • Loading branch information
wookay committed Dec 24, 2023
1 parent ef80f0b commit 9e900f2
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ URIParser = "30578b45-9adc-5946-b283-645ec420af67"

[compat]
Documenter = "0.24, 0.25, 0.26, 0.27"
HTTP = "0.8, 0.9, 1.0"
HTTP = "0.8, 0.9, 1.0, 1.10"
MbedTLS = "0.7, 1.0"
URIParser = "0.4"
JSON = "0.21"
Expand Down
24 changes: 24 additions & 0 deletions test/json/parse.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,27 @@ json_encode = JSON3.write
@test (json_encode json_decode)("[1.0]") == "[1]" #

end # module test_json3_parse


module test_json3_parse_jsonlines

using Test
using JSON3

json_decode(json) = JSON3.read(json, jsonlines=true) #
json_encode = JSON3.write

@test_throws ArgumentError json_decode(IOBuffer())
@test json_decode(IOBuffer("1")) == [1] #
@test json_decode(String(take!(IOBuffer("1")))) == [1] #
@test json_decode(read(IOBuffer("1"), String)) == [1] #
@test (json_encode json_decode)(IOBuffer("[1]")) == "[[1]]" #
@test (json_encode json_decode)(IOBuffer("[1.0]")) == "[[1]]" #

@test_throws ArgumentError json_decode("")
@test json_decode("1") isa JSON3.Array #
@test json_decode("1.0") isa JSON3.Array #
@test (json_encode json_decode)("[1]") == "[[1]]" #
@test (json_encode json_decode)("[1.0]") == "[[1]]" #

end # module test_json3_parse_jsonlines

0 comments on commit 9e900f2

Please sign in to comment.