Serializes data into the Protobuf format

serializeProtobuf(data, schema [, messageType, queryFormat, useCustomSerialization, protoPath]) → returns any

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

Argument Reference

data any

The data to serialize

schema string

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

messageType string

A message type from given schema as string. This is optional if schema contains one and only one message type.

queryFormat string
Default: struct

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

useCustomSerialization boolean
Default: true

Whether to use the customSerializer

protoPath string

Specifies a directory in which the compiler looks for imported files defined in the schema. By default, it will be the current schema's parent path.

Links more information about serializeProtobuf

Sample code invoking the serializeProtobuf function

Serializes a ColdFusion query into an array of Protobuf binary data

news = queryNew("id,title",
    [ {"id":1,"title":"Dewey defeats Truman"}, {"id":2,"title":"Man walks on Moon"} ]);
newsSchema = 'syntax = "proto3";
message News { int32 id = 1; string title = 2; }';
writeDump(serializeProtobuf(news, newsSchema));

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

Fork me on GitHub