6

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.

Devns
  • 63
  • 1
  • 1
  • 4

1 Answers1

8

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

Igor Bernstein
  • 571
  • 2
  • 5
  • 2
    Unfortunately the `toObject` encoding doesn't correctly implement all fields as it should be the proto documentation. E.g. `TimeStamp` should be returned as an ISO timestamp, but instead is an object with properties of `seconds` and `nanos` – Richard Nov 27 '19 at 15:18