tencent cloud

All product documents
Tencent Cloud Observability Platform
protobuf.unmarshal
Last updated: 2025-03-11 20:04:59
protobuf.unmarshal
Last updated: 2025-03-11 20:04:59
protobuf.marshal is used for pb deserialization.
unmarshal(message: string, data: ArrayBuffer, filename?: string): any

Parameters

Parameter
Type
Description
message
string
The struct name.
data
ArrayBuffer
The binary request body.
filename?
string
Optional; the parameter file name.

Return

Type
Description
any
The result obtained from deserialization.

Samples

Call the method for pb deserialization:
import protobuf from 'pts/protobuf';

// Load the demo.proto file from the root directory of the protocol file.
protobuf.load([], 'demo.proto');

// Load the demo.proto file in the dirName directory of the protocol files.
// protobuf.load(['dirName'], 'demo.proto');

export default function () {
// Call marshal for serialization.
const data = protobuf.marshal('xxxx.xxx.demo.stSayHelloReq', { msg: 'pts' });
console.log(data); // [object ArrayBuffer]
// Call unmarshal for deserialization.
const value = protobuf.unmarshal('xxxx.xxx.demo.stSayHelloReq', data);
console.log(JSON.stringify(value)); // {"msg":"pts"}
}

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon