Whatever message this page gives is out now! Go check it out!

SerializeProtoBuf

Last update:
May 18, 2026

Description

Converts ColdFusion data into a Protobuf representation of the data.

Returns

Returns a byte array data or list of byte array.

Syntax

serializeProtoBuf((data, schema, messageType, queryFormat, useCustomSerialisation, protoPath)

Parameters

Parameter Required Description
dataYesA ColdFusion data value or variable that represents one.
schemaYesA protobuf schema. It can be given as plain string or filepath directly.
messageTypeYesA message type from given schema as string. this is optional If schema contains one and only one messagetype.
queryFormatNoThis parameter is of type string with possible values "row", "column", or "struct". The default value is "struct".
useCustomSerializationNoTrue/false. Whether to use the customSerializer or not. The default value is true. Note that the custom serialize will always be used for serialization. If false, the Protobuf serialization will be done using the default ColdFusion behavior.
protoPathNo(True/False) The purpose of the flag is to specify 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.

Example

Customer.proto
syntax = "proto3";
message Customer {
    int64 customer_id = 1;
    string customer_name = 2;
}
Order.proto
syntax = "proto3"; 
import "Customer.proto"; 
message Order {
    int32 order_id = 1;
    string order_date = 2;
    int32 order_amount = 3;
    Customer customer = 5;
}
File.cfm
<cfscript>
    // define the data
    data = {
        "order_id": 32,
        "order_date": "09-09-2022",
        "order_amount": 345,
        "customer":{
            "customer_id":344,
            "customer_name":"Jack"
        }
    }
    protoSerRes = serializeProtoBuf(data,'Order.proto','Order','struct',false); 
    writedump(protoSerRes) // should output data in binary format
</cfscript>

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page