Struct serde_with::json::JsonString [−][src]
pub struct JsonString;
Expand description
Serialize value as string containing JSON
The same functionality is also available as serde_with::json::nested
compatible with serde’s with-annotation.
Examples
#[serde_as] #[derive(Deserialize, Serialize)] struct A { #[serde_as(as = "JsonString")] other_struct: B, } #[derive(Deserialize, Serialize)] struct B { value: usize, } let v: A = serde_json::from_str(r#"{"other_struct":"{\"value\":5}"}"#).unwrap(); assert_eq!(5, v.other_struct.value); let x = A { other_struct: B { value: 10 }, }; assert_eq!( r#"{"other_struct":"{\"value\":10}"}"#, serde_json::to_string(&x).unwrap() );
Trait Implementations
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer.
Serialize this value into the given Serde serializer.
Auto Trait Implementations
impl RefUnwindSafe for JsonString
impl Send for JsonString
impl Sync for JsonString
impl Unpin for JsonString
impl UnwindSafe for JsonString
Blanket Implementations
Mutably borrows from an owned value. Read more