Comments (8)
Update: it turns out this is possible, and we have code that handles this situation. We'll be adding custom options marshalling for JSON in the near future, and the ability to convert to/from JSON/binary images.
from buf.
Hey,
JSON extensions are explicitly impossible:
/**
* Utility classes to convert protobuf messages to/from JSON format. The JSON
* format follows Proto3 JSON specification and only proto3 features are
* supported. Proto2 only features (e.g., extensions and unknown fields) will
* be discarded in the conversion. That is, when converting proto2 messages
* to JSON format, extensions and unknown fields will be treated as if they
* do not exist. This applies to proto2 messages embedded in proto3 messages
* as well.
*/
We'll keep this issue open unitl we update the documentation.
In general, as we said, it's much better to use the wire format than the JSON format when storing Protobuf messages. We don't do any comparisons with custom options for breaking change detection, so it is fine to store JSON messages to use in the breaking change detector, but for other use we would recommend you use the wire format.
from buf.
I think I might be misunderstanding a bit, the official docs say that extensions are explicitly still supported for the purpose of custom options in proto3 (even though that's the only place they're valid). https://developers.google.com/protocol-buffers/docs/proto3#custom_options
Is that not the case?
it's much better to use the wire format than the JSON format when storing Protobuf messages
I'm not actually storing messages, I'm attempting to run custom linting rules on custom options, I was under the impression buf is supposed to help make linting easier, but perhaps I misunderstand buf's goals.
Additional Context from the protocol buffers repo: protocolbuffers/protobuf#1460
from buf.
Extensions are supported for custom options for proto3, but are not encoded in JSON - the above link explains this, protobuf’s JSON encoders (which we do not maintain) do not support it.
We don’t explicitly support custom lint rules on purpose, but of course you are able to build off of our FileDescriptorSet output. However, protobuf does not appear to support custom option encoding in JSON.
from buf.
That is unfortunate. I'm using buf's JSON output to do code generation and the missing options details is a show stopper. The alternative is to use protobufjs/protobuf.js project's pbjs utility which emits options information.
from buf.
We are considering supporting this, stay tuned
from buf.
See #87
from buf.
Released as 0.18.0.
from buf.
Related Issues (20)
- Sign Windows executable
- Add link to docs in `buf config init`
- `buf build` thinks .proto file is directory that should contain Buf workspace file HOT 13
- Storage bucket with different behaviours
- v1.35.1 is broken HOT 2
- Cannot generate import for googleapis datatype under managed mode. HOT 2
- buf breaking fails for annotated tags with v1.35.0 HOT 4
- Using a plugin that defines some options under `_out` HOT 9
- Add post-processing commands HOT 1
- Buf-breaking fails to clone tag in repo HOT 2
- Buf v1.32.0 and newer walks the entire repository tree when using `--path` HOT 3
- build from source failed HOT 1
- Remove IncludeDocsLink from bufconfig.BufYAMLFile
- inputs paths non base directory HOT 5
- inputs paths is not base directory HOT 1
- Lint: One top level entity (message, enum, service) per file HOT 1
- Should we validate `buf.yaml` configuration when pushing? HOT 1
- Clearing up error messages in `bufconfig`
- HEAD~1 is no longer treated as a valid ref HOT 2
- Dangling _ "github.com/gogo/protobuf/gogoproto" import on `buf generate` for uploaded proto files with gogo fields. HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from buf.