Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

jackielii/pb-from-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pb-from-json

Convert js objects to proto objects, useful to use with grpc-web

Official js protobuf have this issue actively discussed:

https://github.com/protocolbuffers/protobuf/issues/1591

protocolbuffers/protobuf#5449

Once the above issues are resolved, this package doesn't need to exist

example:

import { PingRequest } from 'my-service-pb'
import pbFromJson from 'pb-from-json'

const obj = {
    a: 'a',
    b: 'b'
}

const pbObj = pbFromJson(PingRequest, obj)

nested example:

import {PingRequest, PingSubRequest} from 'my-service-pb'
import pbFromJson from 'pb-from-json'

const obj = {
    a: 'a',
    b: {
        c: 'c'
    }
}
const pbObj = pbFromJson(PingRequest, obj, {'b.ctors':PingSubRequest})

About

create protobuf objects from json

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published