-
-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Consider using rustc_serialize::json::encode to obtain json #19
Comments
+1 And according to this post: What's the difference between the “serialize” and “rustc-serialize” crates?, I recommend to use Serde and its macros to serialize/deserialize a struct to/from JSON instead of rustc-serialize. |
I can second the recommendation for Serde, although it does require rust nightly to use it. |
Note that we don't actually serialize data to JSON. We just use the Yes, we need a macro for users to generate their |
Thanks. I understand why you use |
@vayn patches are always welcomed :-) |
Another possibility, when using serde at least, would be to write your own |
@hugoduncan I didn't look into Serde, is it easier to implement Serializer of Serde than ToJson of rustc-serialize? Because most |
@sunng87 The |
@hugoduncan Iooked at Serde, I would like to implement a custom derive for handlebars that generates |
@hugoduncan @vayn check out tojson_macros I just made for generating default |
I'm still learning how to make a procedural macro for custom struct. @sunng87 You're amazing! 👍 |
@vayn :) I'll close this for now. Feel free to reopen if there's any question. |
Rather than force every structure to implement the
ToJson
trait, it might be preferable to allow users to just add a#[derive(RustcEncodable)]
on their structs, and handlebars can obtain a JSON value via therustc_serialize::json::encode
function.The text was updated successfully, but these errors were encountered: