Bird
0
0

You receive messages with JSON strings in Kafka. How do you deserialize them into Java objects?

hard📝 Application Q8 of 15
Kafka - Consumers

You receive messages with JSON strings in Kafka. How do you deserialize them into Java objects?

AUse a custom deserializer that parses JSON into Java objects
BUse StringDeserializer and cast to Java objects directly
CUse IntegerDeserializer since JSON is text
DUse ByteArrayDeserializer and ignore parsing
Step-by-Step Solution
Solution:
  1. Step 1: Understand JSON message format

    JSON messages are strings but need parsing to convert into Java objects.
  2. Step 2: Choose appropriate deserializer

    A custom deserializer can parse JSON strings into Java objects during deserialization.
  3. Final Answer:

    Use a custom deserializer that parses JSON into Java objects -> Option A
  4. Quick Check:

    JSON requires parsing, so custom deserializer needed [OK]
Quick Trick: JSON needs custom deserializer to convert to objects [OK]
Common Mistakes:
  • Casting strings directly to objects
  • Using IntegerDeserializer for JSON
  • Ignoring JSON parsing step

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kafka Quizzes