mlua icon indicating copy to clipboard operation
mlua copied to clipboard

impl FromLua for serde_json::Value

Open lightsing opened this issue 2 years ago • 1 comments

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:

  1. Added a new feature flag for json: A new feature flag named json has been added, dependent on both the serialize feature and the serde_json crate. This allows the conditional compilation of the new implementation, ensuring backward compatibility.

  2. Updated Cargo.toml:

    • Added serde_json as an optional dependency, with version "1.0".
  3. Updated src/value.rs:

    • Added an implementation block for FromLua trait for serde_json::Value.
    • Inside the from_lua method, a value of Lua type is converted to a serde_json::Value, handling any potential conversion errors and wrapping them into the Error::FromLuaConversionError.

lightsing avatar Aug 02 '23 12:08 lightsing

this is amazing

ElhamAryanpur avatar Aug 17 '24 10:08 ElhamAryanpur