API Reference
YYJSON.Parser.parse_json
— Functionparse_json(x::AbstractString; kw...)
parse_json(x::Vector{UInt8}; kw...)
Parse a JSON string x
(or vector of UInt8
) into a dictionary.
Keyword arguments
dict_type::Type{D} = Dict{String,Any}
: Defines the type ofdictionary
into whichobjects
will be parsed.null::Union{Nothing,Missing} = nothing
: Null value.in_situ::Bool
: This option allows the reader to modify and use the input data to store string values, which can slightly improve reading speed.number_as_raw::Bool
: Read all numbers as raw strings without parsing.bignum_as_raw::Bool
: Read big numbers as raw strings.stop_when_done::Bool
: Stop parsing when reaching the end of a JSON document instead of issues an error if there's additional content after it.allow_comments::Bool
: Allow C-style single line and multiple line comments.allow_inf_and_nan::Bool
: Allownan
/inf
` number or case-insensitive literal.allow_invalid_unicode::Bool
: Allow reading invalid unicode when parsing string values.allow_trailing_commas::Bool
: Allow a single trailing comma at the end of an object or array.
Examples
julia> json = """{
"str": "John Doe",
"num": "30",
"array": [1,2,{"a": 3, "b": null}],
"bool": false,
"obj" : {"a": 1, "b": null},
"another": "key"
}
""";
julia> parse_json(json)
Dict{String, Any} with 6 entries:
"another" => "key"
"str" => "John Doe"
"obj" => Dict{String, Any}("b"=>nothing, "a"=>1)
"array" => Any[1, 2, Dict{String, Any}("b"=>nothing, "a"=>3)]
"num" => "30"
"bool" => false
YYJSON.Parser.open_json
— Functionopen_json(path::AbstractString; kw...)
Reads a JSON file from a given path
and parse it into dictionary.
Keyword arguments
Similar to parse_json
.
open_json(io::IO; kw...)
Reads a JSON file from a given io
and parse it into dictionary.
Keyword arguments
Similar to parse_json
.