Skip to content

Commit

Permalink
Use from_slice
Browse files Browse the repository at this point in the history
  • Loading branch information
JopStro committed May 5, 2024
1 parent 1a93e98 commit a7f48ae
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ use serde_json5 as j5;

fn decode<'lua>(lua: &'lua Lua, s: LuaValue<'lua>) -> LuaResult<LuaValue<'lua>> {
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()
Expand Down

0 comments on commit a7f48ae

Please sign in to comment.