From a7f48aef0c20fbc0a3056ccd8633a99e658bfbf6 Mon Sep 17 00:00:00 2001 From: JopStro Date: Sun, 5 May 2024 18:21:43 +0100 Subject: [PATCH] Use from_slice --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 1fbb265..6960d95 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -4,10 +4,10 @@ use serde_json5 as j5; fn decode<'lua>(lua: &'lua Lua, s: LuaValue<'lua>) -> LuaResult> { let s = match s { - LuaValue::String(ref s) => s.to_str(), + LuaValue::String(ref s) => Ok(s.as_bytes()), _ => Err(format!("invalid input type: {}", s.type_name())).into_lua_err(), }?; - let val: Value = j5::from_str(s).map_err(LuaError::external)?; + let val: Value = j5::from_slice(s).map_err(LuaError::external)?; lua.to_value_with( &val, LuaSerializeOptions::new()