SerializeProtoBuf

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
data Yes A ColdFusion data value or variable that represents one.
schema Yes A protobuf schema. It can be given as plain string or filepath directly.
messageType Yes A message type from given schema as string. this is optional If schema contains one and only one messagetype.
queryFormat No This parameter is of type string with possible values "row", "column", or "struct". The default value is "struct".
useCustomSerialization No True/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.
protoPath No (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>

 Adobe

Получайте помощь быстрее и проще

Новый пользователь?

Adobe MAX 2024

Adobe MAX
— творческая конференция

С 14 по 16 октября очно в Майами-Бич и онлайн

Adobe MAX

Творческая конференция

С 14 по 16 октября очно в Майами-Бич и онлайн

Adobe MAX 2024

Adobe MAX
— творческая конференция

С 14 по 16 октября очно в Майами-Бич и онлайн

Adobe MAX

Творческая конференция

С 14 по 16 октября очно в Майами-Бич и онлайн