DeserializeProtoBuf

Description

Converts Protobuf string data representation into CFML data, such as a CFML structure or array.

Returns

The data value in ColdFusion format: a structure, array, query, or simple value.

Syntax

deserializeProtoBuf(data, schema, messageType, queryFormat, useCustomSerialization, 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.
strictMapping 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, serialization will be done using the default ColdFusion behavior.
protoPath No specifes 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

<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) 
    protoDeSerRes=deserializeProtoBuf(protoSerRes,'/protofiles/Orderr.proto','Order',false,false); 
    writeDump(protoDeSerRes) 
</cfscript>

 Adobe

Get help faster and easier

New user?