Repository navigation
Support JSON.jl v1 - #329
Draft
fromelicks wants to merge 1 commit into
Draft
fromelicks wants to merge 1 commit into
fromelicks wants to merge 1 commit into
Conversation
fromelicks
commented
Sep 7, 2026
Comment on lines
+109
to
+119
| sendmsg(io::IO, m) = (jsonprint(io, m); println(io)) | ||
|
|
||
| function recvmsg(io::IO) | ||
| line = readline(io) | ||
| if isempty(line) | ||
| return nothing # EOF, or a truncated read during shutdown | ||
| end | ||
| return jsonparse(line) | ||
| end | ||
|
|
||
| msg(shell::Electron, m) = sendmsg(shell.sock, m) |
Author
There was a problem hiding this comment.
The framing is explicit in both directions because JSON.jl >= 1 dropped the ability to parse a single value off a stream and leave the remainder in the buffer: JSON.parse(::IO) now reads through to EOF, which on a live socket would simply block. Reading one line at a time keeps a message boundary that does not depend on the parser.
JSON.jl v1 changes three things Blink depends on:
- `JSON.parse(::IO)` no longer parses a single value off a stream and
leaves the rest in the buffer; it reads through to EOF. Electron
wrote callback results back-to-back with no delimiter, so on a live
socket
the read loop would simply block. Messages are now newline-delimited
in both directions, matching the framing Blink already used when
sending, and `recvmsg` reads a line at a time;
- `json` is no longer exported, only `public`;
- Non-finite floats throw instead of being written as `null`, and
`allownan=true` emits `NaN`/`Infinity`, which the browser's JSON
parsing rejects. Blink serializes arbitrary user data, so a
`JSONStyle` keeps the old `null` behaviour.
Parsed messages also materialize as `JSON.Object` rather than `Dict`
under v1. They are handed straight to callbacks registered via `handle`,
so `jsonparse` keeps producing `Dict{String, Any}` rather than breaking
every `::Dict` signature downstream.
The version-dependent spellings live in `src/jsoncompat.jl`; JSON.jl
0.21 remains supported.
fromelicks
force-pushed
the
json-1-compat
branch
from
September 7, 2026 18:58
4e0c74d to
d51114a
Compare
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.
Unlike #328 this PR works with JSExpr.jl v0.5.
JSON.jl v1 changes three things Blink depends on:
JSON.parse(::IO)no longer parses a single value off a stream and leaves the rest in the buffer; it reads through to EOF. Electron wrote callback results back-to-back with no delimiter, so on a live socket the read loop would simply block. Messages are now newline-delimited in both directions, matching the framing Blink already used when sending, andrecvmsgreads a line at a time;jsonis no longer exported, onlypublic;null, andallownan=trueemitsNaN/Infinity, which the browser's JSON parsing rejects. Blink serializes arbitrary user data, so aJSONStylekeeps the oldnullbehaviour.Parsed messages also materialize as
JSON.Objectrather thanDictunder v1. They are handed straight to callbacks registered viahandle, sojsonparsekeeps producingDict{String, Any}rather than breaking every::Dictsignature downstream.The version-dependent spellings live in
src/jsoncompat.jl; JSON.jl 0.21 remains supported.This PR depends on JuliaGizmos/WebIO.jl#521 and JuliaGizmos/JSExpr.jl#49.