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

Missing Default trait on json::Json #71

Closed
Byron opened this issue Mar 11, 2015 · 2 comments
Closed

Missing Default trait on json::Json #71

Byron opened this issue Mar 11, 2015 · 2 comments

Comments

@Byron
Copy link

Byron commented Mar 11, 2015

I am trying to implement a google bigquery tabledata.insertAll request, which requires me to allow arbitrary json data within the json-encoded data structure. The official docs present it like this:

{
  "kind": "bigquery#tableDataInsertAllRequest",
  "rows": [
    {
      "insertId": string,
      "json": {
        (key): (value)
      }
    }
  ]
}

The enclosing structure is implementing the Default trait (it's a requirement), which fails to auto-implement as json::Json doesn't implement it for some reason. To my mind, it could be implemented like this:

impl Default for Json {
    fn default() -> Json {
        Json::Null
    }
}

Do you think this can be done, or is there a reason to omit this trait ?

Thank you

@dtolnay
Copy link
Contributor

dtolnay commented Feb 2, 2017

I agree, we have the equivalent in Serde: serde-rs/json#224.

@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

3 participants