deserializeProtobuf

Converts a Protobuf data representation into CFML data.

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
Required

Protobuf serialized data

schema string
Required

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.

strictMapping boolean
Default: true

Specifies whether to convert the Protobuf strictly. If true, converts the Protobuf binary to matching ColdFusion data types.

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 deserializeProtobuf

Examples
Sample code invoking the deserializeProtobuf function

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

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

Fork me on GitHub