Hello, I'm seeking advice on how to serialize a generic record with a
schema that is determined at runtime.  I know that the schema has no nested
records, so I'm wondering if the following is sufficient, or if there are
other considerations I should be aware of:

namespace avro {
  template<>
  struct codec_traits<avro::GenericRecord> {
    static void encode(Encoder& e, const avro::GenericRecord& c) {
      for (int i = 0; i < c.fieldCount(); ++i) {
        avro::encode(e, c.fieldAt(i));
      }
    }

    static void decode(Decoder& d, avro::GenericRecord& c) { /* not needed
*/}
  };
}

Thanks,
Sam

Reply via email to