Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

extra::json doesn't support using Encodable to encode straight to a json value #46

Closed
rust-highfive opened this issue Feb 2, 2015 · 1 comment

Comments

@rust-highfive
Copy link

Issue by huonw
Tuesday Aug 06, 2013 at 14:08 GMT

For earlier discussion, see rust-lang/rust#8335

This issue was labelled with: A-libs, I-papercut in the Rust repository


If one wants to convert an Encodable type to a Json value, then one has to do something like (i.e. encode as JSON to a string and then parse that string):

let foo = something_to_convert_to_json;

let s = do std::io::with_str_writer |w| {
    foo.encode(&mut extra::json::Encoder(w));
};
let json = match extra::json::from_str(s) {
    Ok(j) => j,
    Err(_) => fail!("Rust output some json it doesn't understand itself.")
};
@alexcrichton
Copy link
Contributor

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants