Serializes data into an Avro binary format

serializeAvro(data, writerSchema [, queryFormat, useCustomSerialization]) → returns any

This function requires Adobe ColdFusion 2023 and up.  Not supported on Lucee, etc.

Argument Reference

data any

The data to serialize

writerSchema string

The Avro schema as a string or the absolute path to the schema

queryFormat string

Indicates in which format a query will be serialized
  • row
  • column
  • struct

useCustomSerialization boolean
Default: true

Whether to use the customSerializer

Links more information about serializeAvro

Sample code invoking the serializeAvro function

Serializes a ColdFusion query into an array of Avro binary data

news = queryNew("id,title",
    [ {"id":1,"title":"Dewey defeats Truman"}, {"id":2,"title":"Man walks on Moon"} ]);
newsSchema = '{  
    "namespace": "my.example",
    "type": "record",
    "name": "News",
    "fields": [ {"name":"id","type":"int"}, {"name":"title","type":"string"} ]
writeDump(serializeAvro(data, newsSchema));

Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.

Fork me on GitHub