Skip to content

sglim/protobuf-js-from-object

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

protobuf-js-from-object

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.

Examples

To run example, run the following command in examples folder:

yarn start

How to use it?

Import in Typescript

import { serializeFromObject } from "protobuf-js-from-object";

Import in Javascript

const { serializeFromObject } = require("protobuf-js-from-object");

Usage

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);

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published