confluentinc / confluent-kafka-dotnet

Confluent's Apache Kafka .NET client
https://github.com/confluentinc/confluent-kafka-dotnet/wiki
Apache License 2.0
38 stars 856 forks source link

Question about generic avro consumer #1211

Open codyrehm opened 4 years ago

codyrehm commented 4 years ago

When reading a generic record using something like Consumer<int, GenericRecord>(), if there is a nested record as one of fields on the top-level generic record there does not appear to be any way to get at the values of the fields on the nested record?

i.e. generic record { ... fields: [ "nestedRecord": { "someField": "someValue" } ... ] ... } I dont see a way to get at the value of nestedRecord.someField.

mhowlett commented 4 years ago

a question for the avro repo :-)

note: with v1.4-RC4, we've added support for protobuf and JSON serialization formats. At this stage, we've only added 'specific' serdes, not generic, but in the case of JSON, it wouldn't be too hard to implement the latter (adapt our JSON deserializer).

DarkChocolate commented 3 years ago

Nested record is also a GenericRecord itself, so you can simply extract the data from the nested record:

var contact = (GenericRecord) cr.Message.Value["Contact"]; var postalCode = contact["PostalCode"]; var city = contact["City"];