This project comes from the issue: https://github.com/protocolbuffers/protobuf/issues/1591
There is no fromObject implementation in google-protobuf implementation so I wrote a little bit hacky solution to serialize protobuf object.
To run example, run the following command in examples
folder:
yarn start
import { serializeFromObject } from "protobuf-js-from-object";
const { serializeFromObject } = require("protobuf-js-from-object");
const buffer: Uint8Array = serializeFromObject(obj, SomeProtoClass);
// Save into file or send it via network or whatever...
const classObj = SomeProtoClass.deserializeBinary(buffer);
const pureObj = classObj.toObject(false);