Comments (4)
Thank you for opening the issue along with a pr!
The ignoreUnknownFields
setting is to ignore any extra json fields of a message which are not part of the message definition. For example given the following proto:
message Some {
string foo = 1;
}
If the json value the we receive is:
{"foo": "...", "bar": "..."}
Then bar
is the unknown field, and that is ignored.
Coming to Struct
, it is part of special types called the Well Known Types, it is designed to represent any json value. undefined
is not a valid json value. For example, if I try to do JSON.parse('{"foo": undefined}')
even js will throw an error.
If you are using TypeScript, then the JsonValue
type ensures that a valid json value is passed to the method. The intention for providing a fromJson
is to typically pass the result of JSON.parse
where instead of the raw json string we have the parsed object. So I'd say this is working as intended.
from protobuf-es.
ok, we can work around it for now then. it would be helpful to at least have some flag to ignore the fields, or if you guys ever implement something like .toPlainObject
and .fromPlainObject
. We make extensive use of protobuf Structs and the current ways of manipulating them with protobuf-es are a bit cumbersome. either way thanks for the quick response!
from protobuf-es.
@thesiti92 Maybe toPlainMessage
will be useful?
from protobuf-es.
oh nice, didnt realize you guys added that. I think for structs its a bit more effed because the plain message representation still looks like {kind: <string>, value: <value>}
which isnt super ergonomic to work with. This is all perhaps a consequence of using protobuf structs in typescript at all haha
from protobuf-es.
Related Issues (20)
- Bug: Leading slash for type urls HOT 2
- How to use enums ? HOT 4
- package import key leads to CJS code via proxy HOT 2
- can i use this with nest grpc? HOT 2
- Option for generate only types without static methods HOT 1
- Runtime error on TextEncoder/TextDecoder HOT 4
- Why is the 'message' type field set as optional? HOT 1
- [feat] Option to generate enum with full prefix HOT 11
- Expose `add` method on registry object HOT 1
- Calling FeatureSetDefaults.fromBinary in a non nodejs runtime fails importing @bufbuild/protobuf HOT 2
- Message name collides with imported message name
- Consider providing a convenient accessor for custom options from Desc* types HOT 2
- Serialize (toJson) Timestamp as date HOT 3
- Non optional timestamp HOT 1
- JsonFormat does not work for proto with optional fields HOT 1
- Register Default Registry HOT 2
- Avoid `instanceof` and remove the "node" export condition
- TypeScript resolves CJS type definitions for ESM code with `NodeNext` module resolution HOT 5
- Comparing messages (Diff) 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 protobuf-es.