Add newtype deserialization for Json(_) for parity with Cbor(_).
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
@@ -272,6 +272,12 @@ impl<'a, 'de: 'a> de::Deserializer<'de> for &'a mut Deserializer<'de> {
|
|||||||
{
|
{
|
||||||
match name {
|
match name {
|
||||||
| "$serde_json::private::RawValue" => visitor.visit_map(self),
|
| "$serde_json::private::RawValue" => visitor.visit_map(self),
|
||||||
|
| "Json" => visitor
|
||||||
|
.visit_newtype_struct(&mut serde_json::Deserializer::from_slice(
|
||||||
|
self.record_trail(),
|
||||||
|
))
|
||||||
|
.map_err(|e| Self::Error::SerdeDe(format!("{name}: {e}").into())),
|
||||||
|
|
||||||
| "Cbor" => visitor
|
| "Cbor" => visitor
|
||||||
.visit_newtype_struct(&mut minicbor_serde::Deserializer::new(self.record_trail()))
|
.visit_newtype_struct(&mut minicbor_serde::Deserializer::new(self.record_trail()))
|
||||||
.map_err(|e| Self::Error::SerdeDe(format!("{name}: {e}").into())),
|
.map_err(|e| Self::Error::SerdeDe(format!("{name}: {e}").into())),
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ pub(crate) struct Serializer<'a, W: Write> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Newtype for JSON serialization.
|
/// Newtype for JSON serialization.
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Deserialize, Serialize)]
|
||||||
pub struct Json<T>(pub T);
|
pub struct Json<T>(pub T);
|
||||||
|
|
||||||
/// Newtype for CBOR serialization.
|
/// Newtype for CBOR serialization.
|
||||||
|
|||||||
Reference in New Issue
Block a user