Search code examples
jsonnode.jsprotocol-buffersgoogle-cloud-bigtable

Convert Protobuf response to JSON in NodeJS


How do we convert Protobuf response (eg. from Bigtable NodeJS Client) to JSON/String with correct braces. There are some resources for Python or Java(https://code.google.com/archive/p/protobuf-java-format/) but none for NodeJS yet which I have found. I am fairly new to Bigtable and NodeJS.


Solution

  • I'm not an expert in nodejs, but it seems like the node protobuf library contains a toObject method that will give you a plain javascript object which you can pass to JSON.stringify():

    https://www.npmjs.com/package/protobufjs#usage