{"action":"created","issue":{"url":"https://api.github.com/repos/serde-rs/json/issues/355","repository_url":"https://api.github.com/repos/serde-rs/json","labels_url":"https://api.github.com/repos/serde-rs/json/issues/355/labels{/name}","comments_url":"https://api.github.com/repos/serde-rs/json/issues/355/comments","events_url":"https://api.github.com/repos/serde-rs/json/issues/355/events","html_url":"https://github.com/serde-rs/json/issues/355","id":254890709,"node_id":"MDU6SXNzdWUyNTQ4OTA3MDk=","number":355,"title":"Add a RawValue type","user":{"login":"alteous","id":8549126,"node_id":"MDQ6VXNlcjg1NDkxMjY=","avatar_url":"https://avatars2.githubusercontent.com/u/8549126?v=4","gravatar_id":"","url":"https://api.github.com/users/alteous","html_url":"https://github.com/alteous","followers_url":"https://api.github.com/users/alteous/followers","following_url":"https://api.github.com/users/alteous/following{/other_user}","gists_url":"https://api.github.com/users/alteous/gists{/gist_id}","starred_url":"https://api.github.com/users/alteous/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alteous/subscriptions","organizations_url":"https://api.github.com/users/alteous/orgs","repos_url":"https://api.github.com/users/alteous/repos","events_url":"https://api.github.com/users/alteous/events{/privacy}","received_events_url":"https://api.github.com/users/alteous/received_events","type":"User","site_admin":false},"labels":[{"id":213499259,"node_id":"MDU6TGFiZWwyMTM0OTkyNTk=","url":"https://api.github.com/repos/serde-rs/json/labels/enhancement","name":"enhancement","color":"84b6eb","default":true}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2017-09-03T18:06:53Z","updated_at":"2018-09-20T21:13:25Z","closed_at":null,"author_association":"NONE","body":"It would be helpful to have a type similar to Go's [`json.RawMessage`](https://golang.org/pkg/encoding/json/#RawMessage) that is not tokenized during deserialization, but rather its raw contents stored as a `Vec<u8>` or `&'de [u8]`.\r\n\r\nThe following pseudo-code demonstrates the idea.\r\n```rust\r\n#[derive(Deserialize)]\r\nstruct Struct {\r\n    /// Deserialized normally.\r\n    core_data: Vec<i32>,\r\n\r\n    /// Contents of `user_data` are copied / borrowed directly from the input\r\n    /// with no modification.\r\n    ///\r\n    /// `RawValue<'static>` is akin to `Vec<u8>`.\r\n    /// `RawValue<'a>` is akin to `&'a [u8]`.\r\n    user_data: serde_json::RawValue<'static>,\r\n}\r\n\r\nfn main() {\r\n    let json = r#\"\r\n    {\r\n        \"core_data\": [1, 2, 3],\r\n        \"user_data\": { \"foo\": {}, \"bar\": 123, \"baz\": \"abc\" }\r\n    }\r\n    \"#;\r\n    \r\n    let s: Struct = serde_json::from_bytes(&json).unwrap();\r\n    println!(\"{}\", s.user_data); // \"{ \\\"foo\\\": {}, \\\"bar\\\": 123, \\\"baz\\\": \\\"abc\\\" }\"\r\n}\r\n```\r\n\r\nThe main advantage of this is would be to have 'lazily-deserialized' values."},"comment":{"url":"https://api.github.com/repos/serde-rs/json/issues/comments/423335301","html_url":"https://github.com/serde-rs/json/issues/355#issuecomment-423335301","issue_url":"https://api.github.com/repos/serde-rs/json/issues/355","id":423335301,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMzMzNTMwMQ==","user":{"login":"dtolnay","id":1940490,"node_id":"MDQ6VXNlcjE5NDA0OTA=","avatar_url":"https://avatars2.githubusercontent.com/u/1940490?v=4","gravatar_id":"","url":"https://api.github.com/users/dtolnay","html_url":"https://github.com/dtolnay","followers_url":"https://api.github.com/users/dtolnay/followers","following_url":"https://api.github.com/users/dtolnay/following{/other_user}","gists_url":"https://api.github.com/users/dtolnay/gists{/gist_id}","starred_url":"https://api.github.com/users/dtolnay/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dtolnay/subscriptions","organizations_url":"https://api.github.com/users/dtolnay/orgs","repos_url":"https://api.github.com/users/dtolnay/repos","events_url":"https://api.github.com/users/dtolnay/events{/privacy}","received_events_url":"https://api.github.com/users/dtolnay/received_events","type":"User","site_admin":false},"created_at":"2018-09-20T21:13:25Z","updated_at":"2018-09-20T21:13:25Z","author_association":"MEMBER","body":"I would like for this to be feature gated because it adds code to the critical path of applications even that do not use RawValue. In what ways do you see crates needing to add support for RawValue where the feature gate would be an obstacle?"}}
{"actor":{"display_login":"dtolnay"}}