mlua
mlua copied to clipboard
impl FromLua for serde_json::Value
This pull request introduces the implementation of the FromLua trait for serde_json::Value. This will allow smooth conversion from Lua values to serde_json values and get rid of the 'lua lifetime, providing better integration and flexibility.
Details:
-
Added a new feature flag for json: A new feature flag named
jsonhas been added, dependent on both theserializefeature and theserde_jsoncrate. This allows the conditional compilation of the new implementation, ensuring backward compatibility. -
Updated Cargo.toml:
- Added
serde_jsonas an optional dependency, with version"1.0".
- Added
-
Updated src/value.rs:
- Added an implementation block for
FromLuatrait forserde_json::Value. - Inside the
from_luamethod, a value of Lua type is converted to aserde_json::Value, handling any potential conversion errors and wrapping them into theError::FromLuaConversionError.
- Added an implementation block for
this is amazing