File tree Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Expand file tree Collapse file tree 1 file changed +13
-0
lines changed Original file line number Diff line number Diff line change @@ -35,6 +35,19 @@ impl OtherFields {
35
35
Self { inner }
36
36
}
37
37
38
+ /// Inserts a given value as serialized [`serde_json::Value`] into the map.
39
+ pub fn insert_value ( & mut self , key : String , value : impl Serialize ) -> serde_json:: Result < ( ) > {
40
+ self . inner . insert ( key, serde_json:: to_value ( value) ?) ;
41
+ Ok ( ( ) )
42
+ }
43
+
44
+ /// Inserts a given value as serialized [`serde_json::Value`] into the map and returns the
45
+ /// updated instance.
46
+ pub fn with_value ( mut self , key : String , value : impl Serialize ) -> serde_json:: Result < Self > {
47
+ self . insert_value ( key, value) ?;
48
+ Ok ( self )
49
+ }
50
+
38
51
/// Deserialized this type into another container type.
39
52
pub fn deserialize_as < T : DeserializeOwned > ( & self ) -> serde_json:: Result < T > {
40
53
serde_json:: from_value ( Value :: Object ( self . inner . clone ( ) . into_iter ( ) . collect ( ) ) )
You can’t perform that action at this time.
0 commit comments