{"action":"created","issue":{"url":"https://api.github.com/repos/serde-rs/json/issues/132","repository_url":"https://api.github.com/repos/serde-rs/json","labels_url":"https://api.github.com/repos/serde-rs/json/issues/132/labels{/name}","comments_url":"https://api.github.com/repos/serde-rs/json/issues/132/comments","events_url":"https://api.github.com/repos/serde-rs/json/issues/132/events","html_url":"https://github.com/serde-rs/json/issues/132","id":169692972,"number":132,"title":"Possible to deserialize into existing struct","user":{"login":"andrewrynhard","id":3383143,"avatar_url":"https://avatars.githubusercontent.com/u/3383143?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewrynhard","html_url":"https://github.com/andrewrynhard","followers_url":"https://api.github.com/users/andrewrynhard/followers","following_url":"https://api.github.com/users/andrewrynhard/following{/other_user}","gists_url":"https://api.github.com/users/andrewrynhard/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewrynhard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewrynhard/subscriptions","organizations_url":"https://api.github.com/users/andrewrynhard/orgs","repos_url":"https://api.github.com/users/andrewrynhard/repos","events_url":"https://api.github.com/users/andrewrynhard/events{/privacy}","received_events_url":"https://api.github.com/users/andrewrynhard/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/serde-rs/json/labels/support","name":"support","color":"fef2c0"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":4,"created_at":"2016-08-05T20:45:16Z","updated_at":"2016-08-05T21:17:17Z","closed_at":null,"body":"Hello, is it possible to deserialize a serde_json::Value into an existing struct? Something along the lines of Golang's unmarshal for JSON?"},"comment":{"url":"https://api.github.com/repos/serde-rs/json/issues/comments/237968371","html_url":"https://github.com/serde-rs/json/issues/132#issuecomment-237968371","issue_url":"https://api.github.com/repos/serde-rs/json/issues/132","id":237968371,"user":{"login":"andrewrynhard","id":3383143,"avatar_url":"https://avatars.githubusercontent.com/u/3383143?v=3","gravatar_id":"","url":"https://api.github.com/users/andrewrynhard","html_url":"https://github.com/andrewrynhard","followers_url":"https://api.github.com/users/andrewrynhard/followers","following_url":"https://api.github.com/users/andrewrynhard/following{/other_user}","gists_url":"https://api.github.com/users/andrewrynhard/gists{/gist_id}","starred_url":"https://api.github.com/users/andrewrynhard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andrewrynhard/subscriptions","organizations_url":"https://api.github.com/users/andrewrynhard/orgs","repos_url":"https://api.github.com/users/andrewrynhard/repos","events_url":"https://api.github.com/users/andrewrynhard/events{/privacy}","received_events_url":"https://api.github.com/users/andrewrynhard/received_events","type":"User","site_admin":false},"created_at":"2016-08-05T21:17:17Z","updated_at":"2016-08-05T21:17:17Z","body":"Not for performance. I have a use case where a json has portions of it that I deserialize to a `serde_json::Value` which is then matched to a struct by a String also in the json. \r\nFor example:\r\n\r\n```json\r\n    \"symbols\": {\r\n      \"A\": {\r\n        \"modifier\": {\r\n          \"type\": \"exchange\",\r\n          \"config\": {\r\n            \"value\": \"a\"\r\n          }\r\n        },\r\n        \"provider\": {\r\n          \"type\": \"local\",\r\n          \"config\": {\r\n            \"path\": \"./a.txt\"\r\n          }\r\n        }\r\n      }\r\n```\r\nwhere  `type` is the name of the struct that i use `stringify!` to match against and then the `config` is the `serde_json::Value` that I use to populate the fields. I am attempting to pass these structs in to a macro\r\n```\r\nmacro_rules! deploy {\r\n    ($requisites: ident: $r: expr, $directives: ident: $d: expr, $($modifier: ty), * => $($provider: ty), * => $($deployer: ty), *) => {{\r\n        ...\r\n    }}\r\n}\r\n``` \r\nwhere I would like to create the structs one time and off load any future `Value`s with the same `type` into that struct. Creating one struct at a time adds more complexity to my code in this case. I would like to \"register\" these structs as a sort of service but I cannot register them because the `Value` is not known until later in the code. Sure that makes zero sense without code but it is a bit of a WIP right now."}}
{"actor":{"display_login":"andrewrynhard"}}