If you maintain a Julia service that speaks JSON, you have a problem you may not have noticed yet: JSON3.jl — the package half the ecosystem copied its serialization layer from — is officially deprecated. Its README now leads with a warning banner and a link to a migration guide. The successor isn’t JSON3 v2; it’s JSON.jl v1.0, which absorbed JSON3’s struct-mapping ideas, swapped in StructUtils.jl for extensibility, and changed enough defaults to break code that compiled fine three months ago.
That leaves Julia teams with four real choices in 2026: JSON.jl v1 (the new default), JSON3.jl (fast but sunset), MsgPack.jl (binary, type-driven) and CBOR.jl (RFC 7049, effectively frozen). Picking wrong costs you a rewrite in six months, or a wire format your Go and Python services can’t read.
TL;DR — the 30-second verdict
- New projects, human-readable wire format: use JSON.jl v1. It’s the maintained path, has ordered objects, tries to follow the RFC by default, and struct mapping is now built in.
- Existing JSON3.jl codebases: stay put only if you depend on JSON3’s automatic struct-definition generation; otherwise migrate now — the mapping is mechanical and this article gives you the lookup table.
- High-throughput service-to-service traffic: use MsgPack.jl. Same type-driven mapping ideas as JSON3, roughly half the bytes, and it round-trips Julia types without you writing field-by-field code.
- CBOR.jl: only if an existing C or embedded peer already speaks CBOR. At 19 stars and a last commit in February 2025, treat it as frozen infrastructure, not a growing dependency.
My blunt recommendation: JSON.jl v1 at the edges, MsgPack.jl between your own services. JSON3.jl in 2026 is a legacy liability, and CBOR.jl is a museum piece unless you inherited a binary protocol.
Comparison table (live stats, December 2026)
| JSON.jl v1 | JSON3.jl | MsgPack.jl | CBOR.jl | |
|---|---|---|---|---|
| GitHub stars | 362 | 222 | 68 | 19 |
| Last commit | 2026-11-19 | 2026-11-19 | 2026-11-22 | 2025-02-13 |
| Status | Active, canonical | Deprecated | Active | Frozen |
| Wire format | Text (JSON) | Text (JSON) | Binary (MessagePack) | Binary (CBOR) |
| Struct mapping | Built in via StructUtils.jl | Built in (originals) | Type-driven, overloadable | Manual / minimal |
| Ordered objects | Yes — JSON.Object | Yes | Yes (maps) | Partial |
| Readability in logs | Excellent | Excellent | Poor (needs decoding) | Poor |
| Cross-language peers | Universal | Universal | Very common | Common in IoT/embedded |
| Install | Pkg.add("JSON") | Pkg.add("JSON3") | Pkg.add("MsgPack") | Pkg.add("CBOR") |
Decision matrix — pick in 10 seconds
| Your situation | Use | Why |
|---|---|---|
| Public HTTP API, clients are browsers or curl | JSON.jl v1 | Text format, universal tooling, now spec-compliant by default |
| Internal RPC between Julia services | MsgPack.jl | Fewer bytes, preserves Julia types, less CPU per field |
| Migrating a JSON3.jl codebase | JSON.jl v1 | Documented migration path, same struct-mapping concepts |
| You need JSON3’s “generate struct from sample” | JSON3.jl (temporarily) | Only feature without a clean v1 equivalent yet |
| Peer already speaks CBOR (embedded, COSE, IoT) | CBOR.jl | Don’t re-encode; but pin the version |
| Logs must be greppable by humans | JSON.jl v1 | Compact text output, pretty on demand |
| 100 MB+ payloads between nodes | MsgPack.jl | Binary framing, streaming reads |
JSON.jl v1 — the new baseline
JSON.jl v1 is not a cosmetic bump. Reading and writing now share one set of keyword arguments, JSON.print is a thin alias over JSON.json, and the whole customization surface moved to StructUtils.jl. Install and use:
| |
Two behavioral changes bite people upgrading from 0.21:
JSON.ObjectreplacesDict{String,Any}as the default parse type. It implementsAbstractDict, supports dot access, preserves key order, and uses less memory for small objects. If downstream code mutates nested dicts heavily or relies onDictidentity, passdicttype = Dict{String, Any}explicitly — otherwise you’ll seeMethodErrorin code that assumedDict.allownandefaults tofalse. Files containingNaNorInfthat parsed fine last year now throw. If you ingest instrument data from numerical simulations, setallownan = trueand decide whatNaNshould become on the way back out.
Numbers now parse as Int64, BigInt, Float64, or BigFloat, so decimal IDs no longer silently round into floating point. The inttype keyword is gone; forcing small integer types is no longer on the table.
Typed parsing is the feature that replaces most hand-written construction code:
| |
For types whose serialized form differs from their fields, define JSON.lower:
| |
And when you need custom rules for a type you don’t own, define a style instead of a context:
| |
Writing is where v1 earns its keep: omit_null, omit_empty, jsonlines, float_style (:shortest, :fixed, :exp), float_precision, and inline_limit are all keywords now, so “drop nulls and write one record per line” is one call instead of a custom Serialization subtype:
| |
If you run a Julia web service, this pairs well with the frameworks we compared in Julia web frameworks: Genie vs Oxygen vs HTTP.jl — those stacks all assume JSON.jl as the response encoder.
JSON3.jl — deprecated, and what that actually costs you
JSON3.jl was the performance-and-ergonomics package: it skipped intermediate Dict allocation, let you request JSON3.Object views lazily, and made struct mapping feel natural. Its README now says:
This package has been deprecated. Please migrate to JSON.jl v1 (and see the migration guide).
The migration is mostly renaming:
| JSON3.jl | JSON.jl v1 |
|---|---|
JSON3.read(s) | JSON.parse(s) |
JSON3.read(s, T) | JSON.parse(s, T) |
JSON3.read!(s, x) | JSON.parse!(s, x) |
JSON3.write(x) | JSON.json(x) |
JSON3.pretty(x) | JSON.json(x; pretty = 2) |
JSON3.write(io, x) | JSON.json(io, x) |
JSON3.Object | JSON.Object |
Two caveats. First, lazy JSON3.Object access patterns don’t map one-to-one: JSON.parse materializes, so code that walked a huge document once and touched three fields will now allocate more. If that hot path matters, parse into a struct instead of a generic object. Second, JSON3’s “infer a Julia struct from a sample document” workflow has no direct v1 equivalent — the migration guide itself tells you to keep the old package for that, which is the one legitimate reason to leave the deprecation banner ignored.
Don’t start anything new on it. A deprecated package still receiving commits today is a package that will stop receiving them on someone else’s schedule.
MsgPack.jl — the one to use between your own services
MsgPack.jl describes itself as a “Julia MessagePack implementation with type-driven, overloadable packing/unpacking functionality.” That phrase matters: it means you rarely write per-field code, because the packer walks your type and maps fields into a MessagePack map.
| |
For anything with nested arrays, integer keys, or binary blobs, MessagePack is dramatically cheaper than text JSON: no float formatting, no escaping, no base64 for byte arrays. In a queue consumer processing structured records, that translates into lower allocation pressure and shorter GC pauses — the same reasoning that makes Julia logging choices matter once you’re pushing volume.
The trade-off is operational. msgpack bytes in a log file are unreadable, curl can’t inspect a payload, and every non-Julia peer needs a MessagePack library. Use it behind your service boundary, not at it.
CBOR.jl — correct, standards-based, and effectively frozen
CBOR.jl implements RFC 7049 binary object representation: self-describing, taggable, and a better fit than MessagePack when your peers are embedded devices, COSE-based security stacks, or IoT gateways that standardized on CBOR.
| |
It works, it’s small, and it hasn’t seen a commit since February 2025. That’s not a reason to panic — CBOR as a format is stable — but it is a reason to treat the package as vendored infrastructure: pin the version, and don’t expect new features, Julia 1.13 compatibility patches on day one, or struct-mapping conveniences. If you need typed round-trips and pick CBOR, you’ll write the conversion layer yourself, which is exactly the work MsgPack.jl already did for you.
Performance and pitfalls that actually bite
Measure your own payload, not a leaderboard. JSON3 was faster than JSON.jl 0.21 on large documents because it avoided materializing dicts. JSON.jl v1 changed the default object type and rewrote the writer path, so old benchmark tables are misleading. Benchmark with your real schema: BenchmarkTools.@benchmark JSON.json(payload) versus pack(payload).
Key order is now a feature, not an accident. JSON.Object preserves document order, which is great for signature verification and human diffing — but if you wrote code that assumed hash-order iteration, tests may now fail intermittently in a different way than before.
NaN handling changed direction. Writers still won’t emit invalid JSON unless you opt in with allownan = true. Round-tripping numerical simulation output requires setting it on both read and write, plus ninf/inf/nan string mappings if a downstream browser has to consume the file.
Dict versus JSON.Object is the migration bug you’ll actually hit. Any function annotated ::Dict{String,Any} will reject a parsed object. Prefer AbstractDict in signatures and the problem disappears.
Don’t mix formats per endpoint. A service that returns JSON from /api and MessagePack from /internal is fine; one that returns whichever the client asked for, with different struct-mapping rules per path, will produce a class of bug where a field exists in one format and silently vanishes in the other.
Columnar data doesn’t belong here at all. If you’re moving DataFrames across processes, serialize to Arrow. For table-shaped Julia work, see our DataFrames vs TidierData vs DataFramesMeta comparison — and keep JSON for the API layer.
FAQ
Is JSON3.jl dead?
Effectively yes. The repository README declares it deprecated and points users to JSON.jl v1. It still receives commits as of November 2026, but it is no longer the recommended path and won’t get new features. Migrate new code today; migrate old code when you touch it.
What’s the fastest way to migrate from JSON3.jl to JSON.jl v1?
Rename the calls: JSON3.read → JSON.parse, JSON3.write → JSON.json, JSON3.read! → JSON.parse!, and JSON3.Object → JSON.Object. Then fix the two semantic breaks: JSON.parse returns JSON.Object (not Dict), and allownan now defaults to false. Run your test suite with --check-bounds=yes off and watch for MethodError on Dict annotations.
Should I use MessagePack instead of JSON for a public API?
No. MessagePack is excellent between services you control, but public APIs live on debuggability: browsers, curl, API gateways, and log pipelines all assume text. Keep JSON at the boundary, MessagePack on the wire between your own nodes.
How much smaller is MessagePack than JSON in practice?
For string-heavy records with short keys, typically 20–40% smaller. For numeric arrays, integer-keyed maps, or payloads with binary blobs, savings are much larger because MessagePack stores bytes natively instead of base64. The bigger win is CPU: no float-to-text formatting on the write path.
Does JSON.jl v1 still support pretty printing like the old integer second argument?
Yes, but through keywords: JSON.json(x; pretty = true) or JSON.json(x; pretty = 4) for a four-space indent. The old positional integer form still works but is legacy. Add inline_limit if you want short arrays kept on one line.
Can I read a JSON Lines file with JSON.jl v1?
Yes. Pass jsonlines = true to both the writer and the parser. The writer emits one element per line from an array, and the parser reads that implicit-array format back — which makes it a practical format for appending log records without a wrapper array.
💰 想测试你的市场判断力?我用 Polymarket 做预测市场交易——这是全球最大的预测市场平台,从大选结果到技术监管时间线,什么都可以押注。和赌博不同,这是真正的信息市场:你懂的信息越多,胜率越高。我靠预测技术相关事件的走向已经赚了不少。用我的邀请链接注册:Polymarket.com