From ab7e6de3e1f4a09112b97fa55397e211ee4135a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Mon, 7 Apr 2025 20:15:44 +0200 Subject: [PATCH] xso: Add support for serde_json::Value MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- xso/Cargo.toml | 1 + xso/ChangeLog | 2 ++ xso/src/text.rs | 3 +++ 3 files changed, 6 insertions(+) diff --git a/xso/Cargo.toml b/xso/Cargo.toml index b360f04e03bc6a42dadc511fa987f55460e7acd6..a79b392666141be0d3186619d0f2f041cc7af258 100644 --- a/xso/Cargo.toml +++ b/xso/Cargo.toml @@ -24,6 +24,7 @@ xso_proc = { version = "0.1", path = "../xso-proc", optional = true } jid = { version = "0.12", path = "../jid", optional = true } uuid = { version = "1", optional = true } base64 = { version = "0.22", optional = true } +serde_json = { version = "1.0", optional = true, default-features = false, features = ["alloc"] } [features] default = [ "std" ] diff --git a/xso/ChangeLog b/xso/ChangeLog index d2310f54f9f0d6fb95c924fb857aefe7cafa8362..2e5dd300688ba2523115f0bbdbec97172b55567a 100644 --- a/xso/ChangeLog +++ b/xso/ChangeLog @@ -38,6 +38,8 @@ Version NEXT: for debug logs. - Support to selectively discard attributes or text content during parsing (!552). + - Implement `AsXml` and `FromXml` for serde_json::Value` behind + `serde_json` feature. * Changes - Generated AsXml iterator and FromXml builder types are now doc(hidden), to not clutter hand-written documentation with auto diff --git a/xso/src/text.rs b/xso/src/text.rs index 4fe2565422f7e379bc97b09153a958ab97d561ed..768eabc5402b8a7abb7cf938a592d71edb581837 100644 --- a/xso/src/text.rs +++ b/xso/src/text.rs @@ -128,6 +128,9 @@ convert_via_fromstr_and_display! { jid::DomainPart, #[cfg(feature = "jid")] jid::ResourcePart, + + #[cfg(feature = "serde_json")] + serde_json::Value, } /// Represent a way to encode/decode text data into a Rust type.