Thanks, yes, valid point.
More correctly phrased, I’m generating a JS configuration object based on Julia data (so generating JS code) using JSON.jl. And I need to customize how some of the Julia objects are JSON serialized as the JS library expects a proper JS undefined value.
After more trial and error I seem to have nailed it. Leaving it here for posterity:
JSON.show_json(io::JSON.Writer.StructuralContext, context::JSON.Serializations.CommonSerialization, x::Undefined) = Base.print(io, "undefined")