GithubHelp home page GithubHelp logo

Comments (11)

sjmackenzie avatar sjmackenzie commented on June 22, 2024 2

any movement on this?

from rustc-serialize.

norru avatar norru commented on June 22, 2024 1

Has this been implemented yet?

from rustc-serialize.

alexcrichton avatar alexcrichton commented on June 22, 2024 1

I'm going to close this now that this crate is deprecated in favor of serde. We're discontinuing feature development in rustc-serialize but will still continue to merge bug fixes if they arise.

from rustc-serialize.

fuchsnj avatar fuchsnj commented on June 22, 2024

https://github.com/serde-rs/serde already has something like this

struct Thing {
    #[serde(rename="type")]
    type_ : String
}

or if you want different names for different serializations...

struct Thing {
    #[serde(rename(json="type", xml="type2"))]
    type_ : String
}

from rustc-serialize.

redlolgeerf avatar redlolgeerf commented on June 22, 2024

but serde is not a proper replacement for rustc-serialize, as it's missing some drammatic features like deserealising only part of json fields serde-rs/serde#60

from rustc-serialize.

fuchsnj avatar fuchsnj commented on June 22, 2024

@redlolgeerf I agree serde is not a proper replacement. I was showing that as an example of how it could be implemented.

from rustc-serialize.

redlolgeerf avatar redlolgeerf commented on June 22, 2024

@fenhl , my point is that requested feature is a needed one, despite presence of libraries, that do have it.

from rustc-serialize.

fenhl avatar fenhl commented on June 22, 2024

cc @fuchsnj (assuming @redlolgeerf's comment was supposed to be directed at them)

from rustc-serialize.

aidanhs avatar aidanhs commented on June 22, 2024

I'm interested in this.

from rustc-serialize.

erickt avatar erickt commented on June 22, 2024

@redlolgeerf: The soon to be released serde v0.7.0 will by default automatically ignore unknown fields, with an attribute that restores the old behavior.

from rustc-serialize.

dtolnay avatar dtolnay commented on June 22, 2024

Now that Serde is a proper replacement for rustc-serialize (and more), I think the idea is you should use Serde if you need to customize the serialized representation in any way, including renaming fields.

#[derive(Serialize, Deserialize)]
struct Thing {
    #[serde(rename = "type")]
    ty: String
}

from rustc-serialize.

Related Issues (20)

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.