#[non_exhaustive]pub struct JsonParseOptions {
pub ignore_unknown_enum_values: bool,
pub strict_extension_keys: bool,
}json only.Expand description
Options controlling protobuf JSON parsing behavior.
Use JsonParseOptions::new plus builder methods to construct:
let opts = JsonParseOptions::new().ignore_unknown_enum_values(true);Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.ignore_unknown_enum_values: boolWhen true, unknown enum string values are silently replaced with the
default value (0) for singular fields, or skipped for repeated/map
fields, instead of producing an error.
strict_extension_keys: boolWhen true, "[pkg.ext]" JSON keys that are not in the extension
registry produce a parse error instead of being silently dropped.
The default (false, lenient) matches the pre-extension-registry
behavior where all unknown keys were dropped by serde’s derive.
protobuf-go (protojson/decode.go:175) and protobuf-es
(from-json.ts:251) both error on unregistered extension keys unless
their respective ignore-unknown flags are set; set true here to
match. The error pinpoints the missing registration.
Extendee mismatch (key IS registered but extends a different message) always errors regardless of this flag — that’s a contract violation, not a mere miss.
Implementations§
Source§impl JsonParseOptions
impl JsonParseOptions
Sourcepub fn ignore_unknown_enum_values(self, ignore: bool) -> Self
pub fn ignore_unknown_enum_values(self, ignore: bool) -> Self
Set whether unknown enum string values are ignored (replaced with the default) instead of producing a parse error.
Sourcepub fn strict_extension_keys(self, strict: bool) -> Self
pub fn strict_extension_keys(self, strict: bool) -> Self
Set whether unregistered "[pkg.ext]" JSON keys produce a parse error
(true) or are silently dropped (false, the default).
Trait Implementations§
Source§impl Clone for JsonParseOptions
impl Clone for JsonParseOptions
Source§fn clone(&self) -> JsonParseOptions
fn clone(&self) -> JsonParseOptions
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more