Giter VIP home page Giter VIP logo

serde-lite's People

Contributors

operutka avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

koba-e964

serde-lite's Issues

Implement `Serialize` on `Deserialize` for `Result<T>`

You implement the traits for a wide variety of standard library types, including Option<T>. Any chance you could add an implementation for Result<T, E> where T and E both already implement them? I'm using this in a web framework to reduce Wasm bundle sizes and this would be really helpful for network requests.

Failing Enum deserialization

Čau,
I'm writing an example for MoonZoon and I've probably found a bug in enum deserialization. See errors in comments below.

// main.rs

use serde_lite::{Serialize, Deserialize};
use serde_json;

#[derive(Debug, Serialize, Deserialize)]
enum MyEnum {
    Variant1(Vec<u32>)
}

fn main() {
    let instance = MyEnum::Variant1(vec![
        // 123
    ]);

    // -- Serialization --
    
    let intermediate = instance.serialize().unwrap();
    let json = serde_json::to_string_pretty(&intermediate).unwrap();

    println!("JSON: {}", json);

    // -- Deserialization --

    let intermediate = serde_json::from_str(&json).unwrap();
    // vec![] => error MissingEnumVariantContent'
    // vec![123] => error UnnamedFieldErrors([(0, InvalidValue("array"))])'
    let instance = MyEnum::deserialize(&intermediate).unwrap();

    println!("INSTANCE: {:#?}", instance);
}
# Cargo.toml

[package]
name = "serde_lite_debug"
version = "0.1.0"
edition = "2018"

[dependencies]
# serde-lite = { version = "0.1.1", features = ["derive"] }
serde-lite = { git = "https://github.com/operutka/serde-lite", features = ["derive"] }
serde_json = "1.0.66"

Could you please look at it or direct me to a potential solution?
Thank you.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.