Skip to content

CAMEL-23160: camel-core - Add type converter for camel-util-json#21904

Merged
davsclaus merged 1 commit intomainfrom
jc2
Mar 10, 2026
Merged

CAMEL-23160: camel-core - Add type converter for camel-util-json#21904
davsclaus merged 1 commit intomainfrom
jc2

Conversation

@davsclaus
Copy link
Contributor

Description

Target

  • I checked that the commit is targeting the correct branch (Camel 4 uses the main branch)

Tracking

  • If this is a large change, bug fix, or code improvement, I checked there is a JIRA issue filed for the change (usually before you start working on it).

Apache Camel coding standards and style

  • I checked that each commit in the pull request has a meaningful subject line and body.
  • I have run mvn clean install -DskipTests locally from root folder and I have committed all auto-generated changes.

@github-actions github-actions bot added the core label Mar 10, 2026
@github-actions
Copy link
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using build-all, build-dependents, skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

Copy link
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor observations:

  1. convertToJson() casting — The JsonObject converter casts exchange.getIn().getBody() directly. If the body is a primitive JSON value (string, number), this would throw ClassCastException. However, this is consistent with how other converters in the codebase work (Camel's type converter framework handles the routing).
  2. Shorthand aliases — The PR adds aliases like JsonObject, JsonArray, and Json (for Jsonable) in resolveClass(), but only for the single-arg overload. The ClassLoader-specific overloads don't get the aliases. This is fine for typical usage (convertBodyTo("JsonObject")).
  3. Missing test coverage — There's no test for the Json → Jsonable alias specifically, though the converter tests cover the underlying conversion.

@davsclaus davsclaus merged commit a883172 into main Mar 10, 2026
4 checks passed
@davsclaus davsclaus deleted the jc2 branch March 10, 2026 11:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants