{"id":27305381,"url":"https://github.com/krtab/serde_deser_iter","last_synced_at":"2025-08-23T10:13:20.301Z","repository":{"id":200172412,"uuid":"704973483","full_name":"krtab/serde_deser_iter","owner":"krtab","description":"Iterate through serialized sequences allowing to aggregate them without deserializing to an allocated collection.","archived":false,"fork":false,"pushed_at":"2023-10-16T16:35:02.000Z","size":6071,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-19T04:09:24.577Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/krtab.png","metadata":{"files":{"readme":"Readme.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-10-14T17:04:19.000Z","updated_at":"2024-09-09T18:36:36.000Z","dependencies_parsed_at":"2023-10-16T23:30:22.660Z","dependency_job_id":"7774810e-391d-4d24-bf09-80a2abaa4b21","html_url":"https://github.com/krtab/serde_deser_iter","commit_stats":null,"previous_names":["krtab/serde_iter","krtab/serde_deser_iter"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/krtab/serde_deser_iter","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krtab%2Fserde_deser_iter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krtab%2Fserde_deser_iter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krtab%2Fserde_deser_iter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krtab%2Fserde_deser_iter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krtab","download_url":"https://codeload.github.com/krtab/serde_deser_iter/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krtab%2Fserde_deser_iter/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":271746559,"owners_count":24813570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-23T02:00:09.327Z","response_time":69,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-04-12T03:28:36.750Z","updated_at":"2025-08-23T10:13:20.266Z","avatar_url":"https://github.com/krtab.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"This crate offers two different ways to deserialize sequences without\nallocating.\n\n# Example\n\nGiven the following JSON:\n\n```json\n[\n    {\"id\": 0, \"name\": \"bob\", \"subscribed_to\": [\"rust\", \"knitting\", \"cooking\"]},\n    {\"id\": 1, \"name\": \"toby 🐶\", \"subscribed_to\": [\"sticks\", \"tennis-balls\"]},\n    {\"id\": 2, \"name\": \"alice\", \"subscribed_to\": [\"rust\", \"hiking\", \"paris\"]},\n    {\"id\": 3, \"name\": \"mark\", \"subscribed_to\": [\"rust\", \"rugby\", \"doctor-who\"]},\n    {\"id\": 4, \"name\": \"vera\", \"subscribed_to\": [\"rust\", \"mma\", \"philosophy\"]}\n]\n```\nwe can process it without allocating a 5-sized vector of items as follow:\n\n```rust\nuse serde_deser_iter::top_level::DeserializerExt;\n# use std::{fs::File, io::BufReader, path::PathBuf, collections::HashSet};\n#\n/// The type each item in the sequence will be deserialized to.\n#[derive(serde::Deserialize)]\nstruct DataEntry {\n    // Not all fields are needed, but we could add \"name\"\n    // and \"id\".\n    subscribed_to: Vec\u003cString\u003e,\n}\n\nfn main() -\u003e anyhow::Result\u003c()\u003e {\n    #\n    # let example_json_path: PathBuf = [env!(\"CARGO_MANIFEST_DIR\"), \"examples\", \"data.json\"]\n    #   .iter()\n    #   .collect();\n    let buffered_file: BufReader\u003cFile\u003e = BufReader::new(File::open(example_json_path)?);\n    let mut json_deserializer = serde_json::Deserializer::from_reader(buffered_file);\n    let mut all_channels = HashSet::new();\n\n    json_deserializer.for_each(|entry: DataEntry| all_channels.extend(entry.subscribed_to))?;\n    println!(\"All existing channels:\");\n    for channel in all_channels {\n        println!(\"  - {channel}\")\n    }\n    Ok(())\n}\n```\n\n# Top-level vs deep\n\n## Top-level\n\nThe top_level module offers the most user friendly and powerful way to\ndeserialize sequences. However, it is restricted to sequences defined at\nthe top-level. For example it can work on each `{\"name\": ...}` from the following JSON\n\n```json\n[\n    {\"name\": \"object1\"},\n    {\"name\": \"object2\"},\n    {\"name\": \"object3\"}\n]\n```\n\nbut not if they are deeper in the structure:\n\n```json\n{\n    \"result\": [\n        {\"name\": \"object1\"},\n        {\"name\": \"object2\"},\n        {\"name\": \"object3\"}\n    ]\n}\n```\n\n## Deep\n\nThe deep module allows working on sequences located at any depth\n(and even nested one, though cumbersomely). However it does not allow to\nrun closures on the iterated items, only functions, and its interface is\nless intuitive than top_level.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrtab%2Fserde_deser_iter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrtab%2Fserde_deser_iter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrtab%2Fserde_deser_iter/lists"}