Skip to content

Example in readme is not working #431

@ablaom

Description

@ablaom
import JSON
json = """{"a": 1, "b": null, "c": [1, 2, 3]}"""
j = JSON.parse(json)
struct MyType
    a::Int
    b::Union{Nothing, String}
    c::Vector{Int}
end
j = JSON.parse(json, MyType)
# ERROR: MethodError: no method matching parse(::String, ::Type{MyType})
# The function `parse` exists, but no method is defined for this combination of argument types.
#
# Closest candidates are:
#   parse(::AbstractString; dicttype, inttype, allownan, null)
#    @ JSON ~/.julia/packages/JSON/93Ea8/src/Parser.jl:443
#   parse(::IO; dicttype, inttype, allownan, null)
#    @ JSON ~/.julia/packages/JSON/93Ea8/src/Parser.jl:474
(jl_lnuQYN) pkg> st
Status `/private/var/folders/4n/gvbmlhdc8xj973001s6vdyw00000gq/T/jl_lnuQYN/Project.toml`
  [682c06a0] JSON v1.4.0

julia> versioninfo()
Julia Version 1.11.7
Commit f2b3dbda30a (2025-09-08 12:10 UTC)
Build Info:
  Official https://julialang.org/ release
Platform Info:
  OS: macOS (x86_64-apple-darwin24.0.0)
  CPU: 12 × Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
  WORD_SIZE: 64
  LLVM: libLLVM-16.0.6 (ORCJIT, skylake)
Threads: 12 default, 0 interactive, 6 GC (on 12 virtual cores)
Environment:
  JULIA_LTS_PATH = /Applications/Julia-1.10.app/Contents/Resources/julia/bin/julia
  JULIA_PATH = /Users/anthony/.juliaup/bin/julia
  JULIA_EGLOT_PATH = /Applications/Julia-1.7.app/Contents/Resources/julia/bin/julia
  JULIA_NUM_THREADS = 12
  JULIA_NIGHTLY_PATH = /Applications/Julia-1.11.app/Contents/Resources/julia/bin/julia
  JULIA_PKG_SERVER = pumasai.juliahub.com

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions