Skip to content

Replace deprecated MultiJson constant with JSON.parse#151

Open
maximn wants to merge 1 commit into
heroku:mainfrom
maximn:fix/multijson-deprecation
Open

Replace deprecated MultiJson constant with JSON.parse#151
maximn wants to merge 1 commit into
heroku:mainfrom
maximn:fix/multijson-deprecation

Conversation

@maximn
Copy link
Copy Markdown

@maximn maximn commented May 12, 2026

What

Replace the deprecated MultiJson constant with JSON.parse in the generated client.

Why

The multi_json gem in its 1.21.x line deprecated the CamelCase MultiJson constant in favor of MultiJSON (all-caps), and will remove it entirely in v2.0. As a result, simply loading platform-api now emits a deprecation warning on every Ruby process:

The MultiJson constant is deprecated and will be removed in v2.0. Use MultiJSON instead.

This affects every downstream consumer of platform-api — the warning is emitted whether or not you ever call the Heroku API in your process.

Approach

The generator (heroics) has already fixed this upstream:

  • heroics 0.1.3 template emits MultiJson.load(...)
  • heroics 0.1.4 template emits JSON.parse(...) and removed its multi_json dependency entirely (CHANGELOG)

The platform-api gemspec already allows heroics ~> 0.1.1, so the long-term fix is just bundle update heroics && rake build. However, that produces a noisy ~1,900-line whitespace-only diff (heroics 0.1.4 also tweaked template whitespace), which is hard to review.

This PR applies the single substantive changeMultiJson.loadJSON.parse — directly so the deprecation warning goes away immediately without the whitespace churn. The next time someone runs rake build against heroics >= 0.1.4, the regenerated file will produce the same line.

Compatibility

  • JSON.parse is part of the Ruby standard library — no new dependency.
  • Behavior is identical: both calls parse the embedded JSON schema literal at gem load time.
  • No API changes for consumers.

The multi_json gem (1.21.x) deprecated the CamelCase MultiJson constant
in favor of MultiJSON, and will remove it entirely in v2.0. Loading the
generated client currently emits:

  The MultiJson constant is deprecated and will be removed in v2.0.
  Use MultiJSON instead.

Switch to the stdlib JSON.parse instead, matching what heroics 0.1.4's
generator template already emits (heroics 0.1.4 also dropped its
multi_json dependency). Behavior is unchanged: both calls parse the
same JSON schema literal at load time.

This is a surgical edit to the generated file; a future 'rake build'
against heroics >= 0.1.4 will produce the same line.
@maximn
Copy link
Copy Markdown
Author

maximn commented May 21, 2026

Thanks for the review! That block is a verbatim quote of the deprecation warning emitted by multi_json itself — the gem renamed its own constant from MultiJson to MultiJSON (all-caps), and the warning points users at the new name. Quoting it accurately is intentional so the message is searchable.

The PR's fix is different (and stronger) than what the warning suggests: rather than switching to MultiJSON, we drop the multi_json dependency entirely and use stdlib JSON.parse. That's covered in the "Approach" section below. Happy to add a clarifying sentence if it's confusing — let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants