diff --git a/packages/yew-macro/src/html_tree/html_block.rs b/packages/yew-macro/src/html_tree/html_block.rs
index 07bbab041..bc7b8f9a8 100644
--- a/packages/yew-macro/src/html_tree/html_block.rs
+++ b/packages/yew-macro/src/html_tree/html_block.rs
@@ -32,7 +32,7 @@ impl Parse for HtmlBlock {
BlockContent::Node(Box::new(content.parse()?))
};
- Ok(HtmlBlock { brace, content })
+ Ok(HtmlBlock { content, brace })
}
}
diff --git a/packages/yew/src/format/json.rs b/packages/yew/src/format/json.rs
index ce9f0a826..4c386b0ed 100644
--- a/packages/yew/src/format/json.rs
+++ b/packages/yew/src/format/json.rs
@@ -11,6 +11,8 @@
///
/// // Converts JSON string to a data (lazy).
/// let Json(data) = dump;
+/// // Or another way to convert JSON string to data:
+/// let data = dump.into_inner();
/// ```
#[derive(Debug)]
pub struct Json(pub T);
@@ -19,6 +21,14 @@ text_format!(Json based on serde_json);
binary_format!(Json based on serde_json);
+impl Json {
+ /// Consumes the JSON wrapper and returns the wrapped item.
+ #[inline(always)]
+ pub fn into_inner(self) -> T {
+ self.0
+ }
+}
+
#[cfg(test)]
mod tests {
use super::*;
@@ -41,4 +51,16 @@ mod tests {
let _stored: Text = Json(&data).into();
let _stored: Binary = Json(&data).into();
}
+
+ #[test]
+ fn test_into_inner() {
+ #[derive(Serialize, Deserialize)]
+ struct Data {
+ value: u8,
+ }
+
+ let data: Json> = Json::from(Ok(r#"{"value": 123}"#.to_string()));
+ let data = data.into_inner().unwrap();
+ assert_eq!(data.value, 123);
+ }
}