-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to have connector output JSON String? #398
Comments
@aliadnani Out of curiosity: what happens if you use |
If I use
The double quotes are escaped and I'm guessing the I think what's happening when the value converter is set to I was poking around the camel connector codebase and saw transforms, would it work to write a transform class to take the JsonNode object and format it to a JSON string with the method |
...
I think this would do the trick. We do have a few cases where we do this, in the test code base, for example, so I assume it would be a pretty similar scenario. |
Thank you! It works! I was wrong that the Anyways, I installed a transform library and used the ToJSON SMT to form a JSON string from the Struct before outputting to websocket. My CURL request looks like this now:
And now the output is a proper JSON: I was thinking maybe this should be the default behavior for Sink Connectors dealing consuming non-string data (JSON in my case) and don't have to send data in a specific format. To me it makes more sense that non-string data (JSON, Avro) parsed by their converters to a Struct Object is sent to a websocket (or any other sink) as JSON rather than string-ed struct: Anyways, thanks again for the help! |
This can be close |
Hi, I'm using the Camel Websocket Connecter to send data from a topic to a websocket. The data from the input topic is in Json/JsonSchema format.
The connector works for sending data to the websocket, but the data is in the format of
Struct{key1=val1,key2=val2}
Is it possible to have the connector emit a JSON string like
{"key1":"val1","key2": "val2"}
instead?The task config can be seen via CURL request below:
Thanks!
The text was updated successfully, but these errors were encountered: