aliadnani edited a comment on issue #398:
URL: 
https://github.com/apache/camel-kafka-connector/issues/398#issuecomment-681705905


   If I use `org.apache.kafka.connect.storage.StringConverter` I get the 
following for my topic data serialized with **JSON Schema**:
   
   ```
   
"\u0000\u0000\u0000\u0000\u0001{\"name\":\"temperatureCelsius\",\"value\":23.0,\"unit\":\"C\",\"utc\":1592805755142}"
   ```
   The double quotes are escaped and I'm guessing the 
`\u0000\u0000\u0000\u0000\u0001` at the beginning is the [Magic Byte/Schema 
ID](https://docs.confluent.io/current/schema-registry/serdes-develop/index.html#wire-format)
 thats encoded with the message.
   
   I think what's happening when the value converter is set to 
`JsonSchemaConverter` is that the message is serialized to a Java object (based 
on the [JsonConverter 
source](https://github.com/apache/kafka/blob/trunk/connect/json/src/main/java/org/apache/kafka/connect/json/JsonConverter.java)
 I'm guessing Jackson JsonNode?) and that object gets passed directly to the 
websocket output resulting in something like `Struct{key1=val1,key2=val2}`. 
Whereas, with `StringConverter` the message (inlcuding the schema ID bytes) are 
deserialized to a String object directly resulting in above ^^ funny looking 
JSON.
   
   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 `jsonNode.toPrettyString()` before sending it to 
the websocket output? 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to