Repository navigation
Support JSON.jl v1 - #521
Draft
fromelicks wants to merge 4 commits into
Draft
fromelicks wants to merge 4 commits into
fromelicks wants to merge 4 commits into
Conversation
fromelicks
force-pushed
the
jsonv1-compat
branch
from
September 2, 2026 08:17
998a938 to
03b744c
Compare
Author
`request` is annotated `AbstractDict` rather than `Dict` because it comes straight off the wire: JSON.jl v1 materializes objects as `JSON.Object`, which is an `AbstractDict` but not a `Dict`. A `Dict` annotation in `handle_rpc_request` fails to match, and `dispatch_request` turns the resulting MethodError into an error response, so the RPC silently never runs.
Under JSON.jl < 1, `JSEvalSerialization <: CommonSerialization` wrote `NaN`, `Inf` and `-Inf` as `null`. JSON.jl v1 instead throws an ArgumentError, so interpolating e.g. plot data with `NaN` gaps into a `js"..."` literal failed. Lowered non-finite floats to `nothing` under `JSEvalSerialization` to keep the JSON.jl < 1 output.
Under JSON.jl < 1, `JSON.json` and `JSON.print` wrote `NaN`, `Inf` and `-Inf` as `null`. JSON.jl v1 instead throws an `ArgumentError`, so a `NaN` in an Observable value or a node prop broke messages sent over the Mux and generic HTTP providers as well as rendering nodes and scopes. Routed these through a new `jsonstring`, which lowers non-finite floats to `nothing` under JSON.jl v1, like `JSEvalSerialization` does for `js"..."` interpolation.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related to #519 and JuliaGizmos/JSExpr.jl#49.
JSON.jl v1 removed the
show_jsonserialization-context API thatJSEvalSerializationwas built on (JSON.WriterandJSON.Serializationsno longer exist), so WebIO failed to load withUndefVarError: Writer not defined in JSON. Every other JSON API WebIO uses --json,print,parse,lower,JSONText-- is unchanged.Split the one affected block on
isdefined(JSON, :JSONStyle). On v1,JSEvalSerializationbecomes aJSON.JSONStyleand lowers aJSStringto aJSONText, whichJSON.jsonwrites verbatim -- the same raw splicing the oldshow_jsonmethod did.sort_keys=falsekeeps object keys inDictiteration order, since v1 sortsDictkeys by default; this makes the emitted JavaScript byte-identical under either version.JSON.lower(x::JSString)is deliberately left alone. Lowering it to aJSONTextinstead would splice JSStrings in raw under the default serialization too, so a node prop such asDict("onclick" => js"alert(1)")would serialize to{"onclick":alert(1)}-- not valid JSON. OnlyJSEvalSerializationsplices raw; the new test in test/syntax.jl pins both halves of that.JSONContextandJSONSerializationalias JSON.jl < 1 internals with no v1 equivalent, so they are defined only on that branch. Likewiseverbose_json[], which re-indents a raw fragment across lines, has no v1 equivalent and is documented as < 1 only; nothing in WebIO sets it.Tested on JSON 0.21.4 and 1.7.1: the pure-Julia part of the suite (node, util, syntax, deprecations, render, asset) passes identically on both, 78 tests each.