kcat icon indicating copy to clipboard operation
kcat copied to clipboard

Feature idea: Allow plain JSON payload

Open fabiohecht opened this issue 5 years ago • 4 comments

Idea for a feature I'd find useful:

When I have JSON payload in Kafka and use kafkacat with the -J argument, I would like to have plain JSON as payload. Currently, the payload is always JSON-string-encoded, which makes it hard to use JSON parsers (like jq).

fabiohecht avatar Jan 30 '20 13:01 fabiohecht

Managed to do it like this: kafkacat -C -t ... -e -J -u | jq '.payload=(if .payload==null then null else (.payload|fromjson) end).

fabiohecht avatar Jan 30 '20 14:01 fabiohecht

I like this idea, question is what it should when the payload is not proper json, and thus might mess up the output:

  1. output as-is, this is the easy and performant option, but will break the message structure guarantee.
  2. verify that the json is correct first by deserializing, which is slow.

edenhill avatar Jan 30 '20 18:01 edenhill

I would personally opt for alternative 1, since my applications already guarantee (and rely on) proper JSON. What I would find really useful would be a way to consume from a topic, change the key and/or value (e.g. with jq), and then produce the record to the same or a different topic. For that, we'd need a json producer as well. For my data it would be super useful.

fabiohecht avatar Feb 03 '20 10:02 fabiohecht

Is there some progress?

JakkuSakura avatar Feb 20 '21 13:02 JakkuSakura