You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Scott Carrier (Jira)" <ji...@apache.org> on 2020/10/28 19:24:00 UTC

[jira] [Created] (CAMEL-15769) Ability to disable tokenization on jsonpath split returning a single element as string

Scott Carrier created CAMEL-15769:
-------------------------------------

             Summary: Ability to disable tokenization on jsonpath split returning a single element as string
                 Key: CAMEL-15769
                 URL: https://issues.apache.org/jira/browse/CAMEL-15769
             Project: Camel
          Issue Type: Improvement
          Components: camel-base
    Affects Versions: 3.4.0
            Reporter: Scott Carrier


*Sample json message body:*

{ "text": \{ "div": "some, text" } }

*DSL*

.split(jsonpath("text.div"))

*Result*

The "some, text" string gets split into two pieces: "some" and " text"; (it's split on the comma token).

I do not want the above string to be split on comma tokens, but this appears to happen by default when jsonpath returns a single element as a string value. A workaround is to override the default tokenization by providing some string I hope never appears in the json I process. For example:
.split(jsonpath("text.div").tokenize("@@@"))

If I alter the json as follows, CamelSplitSize is 1 and the output is "some, text" (no split on comma):

{ "text": \{ "div": [ "some, text" ] } } 

I discussed this with Claus on Zulip and this was his response:
 ??"Yeah its a bit of corner case, and as you say you can change the token to @@@ or something. To avoid introducing a new option for a case like this, then we can look at if you specify token="false" then its turned off. You are welcome to create a Jira"??

Only concern with the following is if someone actually wanted to tokenize a string on "false" rather than disable tokenization. Possible I misinterpreted Claus' suggestion though.

.split(jsonpath("text.div").tokenize("false"))

I'd be happy to work on contributing this capability to camel and/or unit test cases to help facilitate a contribution.

Thanks in advance



--
This message was sent by Atlassian Jira
(v8.3.4#803005)