protocolbuffers / protobuf-javascript

BSD 3-Clause "New" or "Revised" License
330 stars 66 forks source link

Convert response message to JSON/Object #161

Closed nickwinger closed 1 year ago

nickwinger commented 1 year ago

Hello,

i finally made a grpc request and now i cannot do anything good with the response yet. If i use the toObject method the string values still have the "value" property in it instead of a real/native string. How can i convert the response message to JSON or real javascript object. If i would have the real JSON i can then make the object by myself...

I thought that the purpose of the strong typed protobuf is that in every language i get the real objects to work with (ORM Mapping) and not some wrappers...

Why in the sourcecode is this? :

export namespace StringValue { export type AsObject = { value: string, } } AsObject should return just a string, and not again a wrapper containing the value property...

Or at least there should be methods like toNativeObject, or doOrmMapping, whatever i want to get out of the wrapper to have the real object...

Thanks

dibenede commented 1 year ago

toObject just returns a JS Object and not the proto3 JSON representation of the proto. This library doesn't implement proto3 JSON.

Closing as dupe of #95 and #28