tencent cloud

Tencent Cloud Observability Platform

Module Overview

PDF
포커스 모드
폰트 크기
마지막 업데이트 시간: 2025-03-11 20:04:59
The pts/protobuf module in the JavaScript API implements protobuf-related features.

Methodology

Methodology
Return Type
Description
void
Load pb files.
ArrayBuffer
Perform pb serialization.
any
Perform pb deserialization.

Samples

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"}
}


도움말 및 지원

문제 해결에 도움이 되었나요?

피드백