pub struct JsonCodec { /* private fields */ }Expand description
JSON codec for schema-based serialization and deserialization.
This codec implements the Smithy JSON protocol serialization rules, with configurable behavior for different protocol variants (e.g., AWS JSON RPC vs REST JSON).
§Examples
use aws_smithy_json::codec::{JsonCodec, JsonCodecSettings};
use aws_smithy_schema::codec::Codec;
use aws_smithy_types::date_time::Format;
// Create codec with default settings (REST JSON style)
let codec = JsonCodec::new(JsonCodecSettings::default());
// Create codec for AWS JSON RPC (no jsonName, epoch-seconds timestamps)
let codec = JsonCodec::new(JsonCodecSettings {
use_json_name: false,
default_timestamp_format: Format::EpochSeconds,
allow_unknown_union_members: false,
});
// Use the codec
let _serializer = codec.create_serializer();
let _deserializer = codec.create_deserializer(b"{}");Implementations§
Source§impl JsonCodec
impl JsonCodec
Sourcepub fn new(settings: JsonCodecSettings) -> Self
pub fn new(settings: JsonCodecSettings) -> Self
Creates a new JSON codec with the given settings.
Sourcepub fn settings(&self) -> &JsonCodecSettings
pub fn settings(&self) -> &JsonCodecSettings
Returns the codec settings.
Trait Implementations§
Source§impl Codec for JsonCodec
impl Codec for JsonCodec
Source§type Serializer = JsonSerializer
type Serializer = JsonSerializer
The serializer type for this codec.
Source§type Deserializer = JsonDeserializer
type Deserializer = JsonDeserializer
The deserializer type for this codec.
Source§fn create_serializer(&self) -> Self::Serializer
fn create_serializer(&self) -> Self::Serializer
Creates a new serializer for this codec.
Source§fn create_deserializer(&self, input: &[u8]) -> Self::Deserializer
fn create_deserializer(&self, input: &[u8]) -> Self::Deserializer
Creates a new deserializer for this codec from the given input bytes.
Auto Trait Implementations§
impl Freeze for JsonCodec
impl RefUnwindSafe for JsonCodec
impl Send for JsonCodec
impl Sync for JsonCodec
impl Unpin for JsonCodec
impl UnwindSafe for JsonCodec
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more