![](/img/trans.png)
[英]Why is the Protobuf blob heavier than the JSON equivalent?
我正在嘗試使用 protobuf 來加速我的前端和后端之間的數據傳輸。 作為 POC,我嘗試加載一個 JSON 文件,將其轉換為 protobuf 緩沖區,並將結果保存在一個新文件中。 但事實證明,新文件比 JSON 文件重。 我做錯什么了嗎? 這是我的文件:// input.proto syn ...
[英]Why is the Protobuf blob heavier than the JSON equivalent?
我正在嘗試使用 protobuf 來加速我的前端和后端之間的數據傳輸。 作為 POC,我嘗試加載一個 JSON 文件,將其轉換為 protobuf 緩沖區,並將結果保存在一個新文件中。 但事實證明,新文件比 JSON 文件重。 我做錯什么了嗎? 這是我的文件:// input.proto syn ...
[英]protobufjs encode a wrapper message which includes an inner field with type google.protobuf.Any
我在 Nodejs 中使用 protobufjs 庫向 kafka 主題發送消息並從 java 消費者讀取消息。 以下是 protobuf 定義。 Inner 消息應該打包在 Wrapper 消息字段中。 我使用以下三種方法對消息進行編碼,但在反序列化時出現錯誤“任何消息的類型與給定的 class ...
[英]Import shared protobuf package into different protobuf packages
我正在為一個項目設計一些protobuf模式,我想要的是有獨立的包,和一個共享的 package。請看下面的例子。 我嘗試了上述方法來設計我需要的東西,但是它不起作用,出現錯誤Import Error: ./shared.proto is not found or has some error 現在 ...
[英]ProtoBuf - Can a field support two possible datatypes?
protobuf 中的一個字段是否有可能支持/接受字符串或字符串數組。 這是我的信息: 它是動態的原因是因為字符串數組或簡單字符串可以作為輸入。 如果有效載荷是 string[] 或 string,則有不同的方法來處理會發生什么。 現在,我正在使用any但我不確定在any文件中做什么。 我讀過o ...
[英]`Could not make proto path relative` for protoc.js
問題在我的 C++ 項目中,我使用 protobuf 通過調用protobuf_generate_cpp cmake 宏來生成一些文件。 生成的make文件如下: 這有效,文件層次結構是: 當我使用emcmake和emmake構建同一個項目時,我得到了生成的 make 文件: 但我得到了錯誤: 但 ...
[英]protobuf.js using CommonJS?
我對 JS 比較陌生,但對 protobuf 非常熟悉。 我目前正在設計從 Java HTTP 服務器托管的 web 頁面,並希望在它們之間實現 protobuf 通信。 我的問題在瀏覽器端。 經過一番研究,我發現了protobuf.js git 頁面並嘗試在我的 javascript 中使用它。 ...
[英]Protobuf structure for a map where the value is an array of objects?
我正在尋找在protobuf中編碼這樣的地圖: 該值是一個對象數組,它們都具有相同的接口(帶有一個可選條目): 我的問題是我將如何將此地圖編碼為 protobuf 消息中的字段。 還是我應該將地圖轉換為另一種格式? 這是使用 protobuf.js npm 模塊。 ...
[英]How to read value of custom options from protobuf.js generated code?
類似於以下示例: https://developers.google.com/protocol-buffers/docs/proto#extensions 假設我有一個像這樣的原型: 然后我使用 protobufjs-cli 生成一個 static 模塊: 然后如何使用生成的模塊讀取 javasc ...
[英]Protobuf : pass protobuf message from Javascript to C++ WebAssembly module
我想將 Javascript 的 protobuf 消息傳遞給 C++ WebAssembly 模塊。 我確實收到並可以在 C++ 端成功解析更簡單的 protobuf 消息,但是,protobuf 無法解析不太簡單的 protobuf 消息。 這是我正在使用的代碼:goog.module('pro ...
[英]How can we convert .proto file and JSON descriptors?
我想從 .proto 文件轉換為 JSON 描述符。 .proto 文件是這樣的: https : //github.com/protobufjs/protobuf.js/blob/master/google/protobuf/type.proto JSON 描述符是這樣的: https : ...
[英]How to write a series of Messages into a file and read them back using protobuf (protobuf.js with proto3)?
我嘗試了該示例,並且能夠使一條消息起作用:// awesome.proto package awesomepackage; syntax = "proto3"; message AwesomeMessage { string awesome_field = 1; // becomes a ...
[英]How to actually see protobuf passing some bytes across, either on the network or in a file?
我是 protobuf 的新手,想通過網絡或文件傳遞一些數據來試驗它,例如 字節可以由Python / Ruby寫入文件,然后由JavaScript讀回嗎? (或者可以全部用 JavaScript 編寫)。 我認為能夠在本地網站上傳遞它可能要復雜得多? 如果是這樣,將其寫入文件並能夠讀回就可以了 ...
[英]Trying to set protobuf Map entries in Typescript
我有以下 protobuf 消息: 在 typescript 中,我試圖根據 typescript Z46F3EA056CAA31026CZF1 設置 protobuf 消息的 map 條目,看起來像這樣。 我嘗試遍歷 map object 中的條目並以這種方式設置 map 條目。 我收到錯誤“Ty ...
[英]Prefix protobuf message with signed 4 byte int
我正在使用 Websocket API ,我將 protobuf 對象發送到。 文檔說: 服務器對二進制數據使用 Big Endian 格式。 來回發送的消息需要一個有符號的 4 字節 int 的消息大小,作為消息的前綴因此有效負載應該是一個 4 字節的 int,其中包含消息大小,然后是消息本身。 ...
[英]How to force typescript to interpret a parameter as a namespace rather than a class, when they have the same name - gRPC
抱歉標題太長了... 我正在使用 gRPC 和 typescript 實現一個簡單的小系統,我的問題是:自動生成的文件為我的protoFile中的每個參數創建了一個 class 和一個類型,例如:UserId 參數生成一個帶有 getUserId 的 ZA2F2ED4F8EBC2CBB14C21A ...
[英]Kafka Protobuf Console Consumer Serialization Exception
我有一個關於 #protobuf #serialization 的問題,它發生在 #nodejs 和 #apache #kafka 中,由 #confluent 平台運行在一個社區中。 我使用 google protobuf 或 protobufjs 序列化數據,然后使用 kafkajs 將其發送到 ...
[英]Is there any way to decode/encode by tag but without any .proto file or json file in protobuf.js?
有什么方法可以按標簽解碼/編碼,但在 protobuf.js 中沒有任何 .proto 文件或 json 文件? 或者其他圖書館? 像:// read value by tag var pb = new Protobufjs.Reader(buffer); var value = pb.readI ...
[英]Encode and decode protocol buffer any type message
我有一個看起來像這樣的原始文件。 然后我嘗試對消息進行編碼和解碼,我丟失了google.protobuf.Any類型的信息。 有誰知道這是為什么? ...
[英]Possible to post to Apollo server with protobuf?
我正在開發一個項目,該項目目前使用 protobuf 從客戶端與 api 進行通信。 我想做一個概念證明,顯示通過 graphql 進行的通信,並且想知道是否可以將 protobuf 發送到 apollo 服務器而不是 json。 還詢問了阿波羅服務器的頻譜: https://spectrum.c ...
[英]Typescript enums as interfaces
我正在使用一個用於 TS 生成的庫(ts-protoc-gen),它為枚舉生成以下內容: 我應該如何消費它? 它如何在不初始化的情況下導出 const? ...