commit ec3d76d09f875dc4b98668eb44947586ff2d4c3c
parent 3707f95281d0fd6555562a1cce3b0a0a0ceb52f8
Author: Erik Loualiche <[email protected]>
Date: Fri, 6 Feb 2026 18:06:51 -0600
Broaden JSON.jl compatibility to 0.21-1.0
Support both JSON 0.21 (for LanguageServer compatibility) and JSON 1.0.
Typed parsing (nickel_eval with type argument) requires JSON >= 1.0.
The native FFI functions don't require JSON at all.
Co-Authored-By: Claude Opus 4.5 <[email protected]>
Diffstat:
3 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/Project.toml b/Project.toml
@@ -7,7 +7,7 @@ version = "0.4.0"
JSON = "682c06a0-de6a-54ab-a142-c8b1cf79cde6"
[compat]
-JSON = "1"
+JSON = "0.21, 1"
julia = "1.6"
[extras]
diff --git a/src/ffi.jl b/src/ffi.jl
@@ -82,6 +82,10 @@ end
function nickel_eval_ffi(code::String, ::Type{T}) where T
result_json = _eval_ffi_to_json(code)
+ if !hasmethod(JSON.parse, Tuple{String, Type})
+ error("Typed parsing requires JSON.jl >= 1.0. " *
+ "Either upgrade JSON.jl or use nickel_eval_native() which doesn't require JSON.")
+ end
return JSON.parse(result_json, T)
end
diff --git a/src/subprocess.jl b/src/subprocess.jl
@@ -134,6 +134,10 @@ julia> nickel_eval("{ x = 1.5, y = 2.5 }", @NamedTuple{x::Float64, y::Float64})
"""
function nickel_eval(code::String, ::Type{T}) where T
json_str = nickel_export(code; format=:json)
+ if !hasmethod(JSON.parse, Tuple{String, Type})
+ error("Typed parsing requires JSON.jl >= 1.0. " *
+ "Either upgrade JSON.jl or use nickel_eval_native() which doesn't require JSON.")
+ end
return JSON.parse(json_str, T)
end
@@ -185,6 +189,10 @@ end
function nickel_eval_file(path::String, ::Type{T}) where T
json_str = _eval_file_to_json(path)
+ if !hasmethod(JSON.parse, Tuple{String, Type})
+ error("Typed parsing requires JSON.jl >= 1.0. " *
+ "Either upgrade JSON.jl or use nickel_eval_file_native() which doesn't require JSON.")
+ end
return JSON.parse(json_str, T)
end