Repository navigation
Support JSON 3 - #1687
Support JSON 3#1687
Conversation
|
This is great, thank you for contributing! I don't think we have tests that cover this, as it would require the Oj library to be added (which would be fine actually, in the Gemfile), so I was thinking we should at least make sure that one accepts the same change in call structure before shipping a release and risking to break every app using a custom decoder on a minor release. |
|
If you wish to make changes to this, I suggest instead of taking a method name and arguments, just take either a Proc, or an object that respond to the standard |
|
Hi there.
However, because this patch has not been released yet, the following error occurs in Do you have any plans to release a new version that includes this patch? |
|
This fix isn't in a release yet (latest is v2.14.3). Worked around it in the meantime with a custom middleware: dblock/strava-ruby-client#115. Looking forward to a new Faraday release with this included! (Comment posted by an AI on behalf of @dblock.) |
|
@olleolleolle When the next release will be cut please? |
|
@crevete It looks like v2.14.4 has already been released. @olleolleolle Thanks for the release! |
|
Verified in dblock/strava-ruby-client#115: Faraday v2.14.4 fixes the Thanks for the fix and release! Posted by an AI on behalf of @dblock. |
While @byroot has done great work in ensuring the ecosystem is compatible with `json` v3, it seems like a few gems still need to catch-up - notably, both [Rails](rails/rails#58601) and [Faraday](lostisland/faraday#1687) have not yet released their compatibility fixes. Interestingly only our `devise` variant actually fails, but in an internal app with 100% coverage I only needed to patch Rails & Faraday to have everything seemingly working and `devise` does not seem to use JSON directly itself. I think overall it's better to play it safe and pin ourselves to JSON v2 at least until Rails has released their patch
…251) Unblocks #248 (Dependabot's rubocop 1.90.0 → 1.91.0 bump). ## What breaks in #248 The rubocop bump re-resolves `json` from 2.21.2 to 3.0.2, and json 3.0 makes every parser option a keyword argument. faraday 2.14.3's JSON response middleware still passes them as a positional hash, so `JSON.parse(body, {})` raises: ``` ArgumentError: wrong number of arguments (given 2, expected 1) json-3.0.2/lib/json/common.rb:296:in 'JSON.parse' faraday-2.14.3/lib/faraday/response/json.rb:36:in 'Faraday::Response::Json#parse' ``` Every spec that mounts a host's `conn.response :json` middleware fails the same way — 29 failures on both the Ruby 4.0.6 and the Ruby 3.3 job. Nothing in `lib/` calls `JSON.parse`/`JSON.generate` with positional options; the library itself is fine on json 3. ## The fix faraday 2.14.4 (released 2026-09-15, the day after #248's CI run) ships lostisland/faraday#1687 "Support JSON 3". `bundle update faraday --conservative` moves faraday alone — the entire diff is: ```diff - faraday (2.14.3) + faraday (2.14.4) ``` The gemspec's `faraday ~> 2.0` already admits it, so nothing changes for gem consumers. ## Verification - On #248's branch (json 3.0.2) with faraday bumped to 2.14.4: the 26 middleware examples pass, and the full suite is 4397 examples, 0 failures on Ruby 4.0.6. - On this branch (json 2.21.2): rubocop clean across 232 files; full suite 4398 examples with one failure, the pattern-timeout spec that #247 also trips — it is timing-dependent and unrelated to faraday (this run shared the CPU with a second suite). Its fix is the sibling PR "test: make the pattern-timeout spec exhaust its budget in the match, not the preflight". - `bundle check` satisfied. ## After merging Comment `@dependabot rebase` on #248 so it re-resolves on top of this lockfile. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
In the upcoming
json 3.x,JSON.parseandJSON.loadtake keyword arguments rather than a positional option Hash.So the options must be splatted.
Thankfully, when splatting on a method that doesn't take keyword arguments, Ruby pass the arguments as positional:
So the change is compatible with both
json 2.xandjson 3.x