Claus Ibsen created CAMEL-26324:
-----------------------------------

             Summary: camel-core - type converter from JsonObject and JsonArray 
to their JSON text
                 Key: CAMEL-26324
                 URL: https://issues.apache.org/jira/browse/CAMEL-26324
             Project: Camel
          Issue Type: Improvement
          Components: camel-core
            Reporter: Claus Ibsen
             Fix For: 4.24.0


camel-support has type converters from text (String, byte[], InputStream, File) 
to the camel-util-json types JsonObject and JsonArray, but none back to text.

Today a JsonObject converted to String gives the toString of a LinkedHashMap, 
which is not JSON:

{noformat}
{sku=CAMEL-MUG, qty=3, tags=[a, b]}
{noformat}

and converted to byte[] or InputStream gives null (no converter). So a 
JsonObject body (graphql, kubernetes-custom-resources, typesafe-ai, or 
convertBodyTo JsonObject) sent to http, file or a messaging producer gives the 
wrong text or fails.

Add regular type converters from JsonObject and JsonArray to String, byte[] and 
InputStream that give their JSON text (Jsoner), using the exchange charset for 
bytes.

This also settles an open question of the payload mode design (CAMEL-25334, 
design/payload-mode.adoc): the json payload mode can use these converters at 
the edges instead of a fallback converter of its own.

_Claude Code on behalf of davsclaus_



--
This message was sent by Atlassian Jira
(v10.3.26#10030026)

Reply via email to