I am new to Kafka.I am trying to write a consumer. I am getting data from multiple tables of a database using only a single kafka topic. The messages which are coming in the below format:
{"TABLE":{"string": "TABLE1"},"NAME":{"string":"JOHN"},"AGE":{"string":"26"},"ADDRESS":{"string":"USA"}
{"TABLE":{"string": "TABLE2"},"NAME":{"string":"RYAN"},"AGE":{"string":"30"},"ADDRESS":{"string":"CANADA"},"PIN":{"string":"000001"},"PHN":null,"STATUS":{"string":"MARRIED"}}
What kind of data format it is? JSON or AVRO? How to parse this using scala?
its json. you may parse it as:
import scala.util.parsing.json.JSON
val result = JSON.parseFull("""{"TABLE":{"string": "TABLE1"},"NAME":{"string":"JOHN"},"AGE":{"string":"26"},"ADDRESS":{"string":"USA"}""")
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.