From 0bd0c361297903888c1f53af67d547ef2858882f Mon Sep 17 00:00:00 2001 From: nsfisis Date: Fri, 5 Jun 2026 05:10:50 +0900 Subject: refactor(json): make json encode helpers accept serde::Serialize Change json_encode/json_encode_ex and JsonFile::encode/encode_with_options to take a generic serde::Serialize value instead of &PhpMixed, implement Serialize for PhpMixed/ArrayObject, and drop the PhpMixed::String wrapping at JsonManipulator call sites in favor of passing raw values. Co-Authored-By: Claude Opus 4.8 (1M context) --- crates/shirabe/src/json/json_file.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'crates/shirabe/src/json/json_file.rs') diff --git a/crates/shirabe/src/json/json_file.rs b/crates/shirabe/src/json/json_file.rs index 06f3946..0aa44fc 100644 --- a/crates/shirabe/src/json/json_file.rs +++ b/crates/shirabe/src/json/json_file.rs @@ -426,11 +426,14 @@ impl JsonFile { Ok(true) } - pub fn encode(data: &PhpMixed) -> String { + pub fn encode(data: &T) -> String { Self::encode_with_options(data, JsonEncodeOptions::default()) } - pub fn encode_with_options(data: &PhpMixed, options: JsonEncodeOptions) -> String { + pub fn encode_with_options( + data: &T, + options: JsonEncodeOptions, + ) -> String { let json = json_encode_ex(data, options.to_flags()); let json = match json { -- cgit v1.3.1