{"id":20887969,"url":"https://github.com/canop/deser-hjson","last_synced_at":"2025-05-12T20:30:46.588Z","repository":{"id":43875031,"uuid":"323161232","full_name":"Canop/deser-hjson","owner":"Canop","description":"A Serde 1.0 compatible Rust deserializer for Hjson","archived":false,"fork":false,"pushed_at":"2023-11-28T17:28:48.000Z","size":87,"stargazers_count":29,"open_issues_count":2,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-01T10:35:50.943Z","etag":null,"topics":["hacktoberfest","json","rust","serde"],"latest_commit_sha":null,"homepage":"","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Canop.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2020-12-20T20:42:59.000Z","updated_at":"2025-02-15T19:18:09.000Z","dependencies_parsed_at":"2023-01-30T04:16:08.982Z","dependency_job_id":"652f3a6a-8f89-42ec-ae73-961184b9fcfd","html_url":"https://github.com/Canop/deser-hjson","commit_stats":{"total_commits":36,"total_committers":2,"mean_commits":18.0,"dds":0.08333333333333337,"last_synced_commit":"882439a13f2fd8832aa6fb9557ad53b32d0c52a0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Canop%2Fdeser-hjson","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Canop%2Fdeser-hjson/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Canop%2Fdeser-hjson/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Canop%2Fdeser-hjson/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Canop","download_url":"https://codeload.github.com/Canop/deser-hjson/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253816652,"owners_count":21968859,"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","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":["hacktoberfest","json","rust","serde"],"created_at":"2024-11-18T08:23:37.952Z","updated_at":"2025-05-12T20:30:45.269Z","avatar_url":"https://github.com/Canop.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![MIT][s2]][l2] [![Latest Version][s1]][l1] [![docs][s3]][l3] [![Chat on Miaou][s4]][l4]\n\n[s1]: https://img.shields.io/crates/v/deser-hjson.svg\n[l1]: https://crates.io/crates/deser-hjson\n\n[s2]: https://img.shields.io/badge/license-MIT-blue.svg\n[l2]: LICENSE\n\n[s3]: https://docs.rs/deser-hjson/badge.svg\n[l3]: https://docs.rs/deser-hjson/\n\n[s4]: https://miaou.dystroy.org/static/shields/room.svg\n[l4]: https://miaou.dystroy.org/3768\n\n# deser_hjson\n\nThis is a Serde deserializer for [Hjson](https://hjson.github.io/), tailored for derive powered deserialization.\n\nHjson is a good language for a configuration file.\nSuch files should be written by a human, read and modified by other humans, then deserialized into a precise structure by a program:\n\n```rust\nlet file_content = fs::read_to_string(\u0026file_path)?;\nlet configuration = deser_hjson::from_str(\u0026file_content);\n```\n\nIf the configuration file is invalid or doesn't match the expected type, the error details the expectation and the error precise location.\n\n## Example\n\n\n```rust\nuse {\n    deser_hjson::*,\n    serde::Deserialize,\n    std::collections::HashMap,\n};\n// This Hjson document comes from https://hjson.github.io/\nlet hjson = r#\"\n// use #, // or /**/ for comments,\n// omit quotes for keys\nkey: 1\n// omit quotes for strings\ncontains: everything on this line\n// omit commas at the end of a line\ncool: {\n  foo: 1\n  bar: 2\n}\n// allow trailing commas\nlist: [\n  1,\n  2,\n]\n// and use multiline strings\nrealist:\n  '''\n  My half empty glass,\n  I will fill your empty half.\n  Now you are half full.\n  '''\n\"#;\n// we'll deserialize it into this struct:\n#[derive(Deserialize, PartialEq, Debug)]\nstruct Example {\n    key: i32,\n    contains: Option\u003cString\u003e,\n    cool: HashMap\u003cString, u16\u003e,\n    list: Vec\u003cusize\u003e,\n    realist: String,\n    missing: Option\u003cf64\u003e,\n}\nlet mut cool = HashMap::new();\ncool.insert(\"foo\".to_owned(), 1);\ncool.insert(\"bar\".to_owned(), 2);\nlet expected = Example {\n    key: 1,\n    contains: Some(\"everything on this line\".to_owned()),\n    cool,\n    list: vec![1, 2],\n    realist: \"My half empty glass,\\nI will fill your empty half.\\nNow you are half full.\".to_owned(),\n    missing: None,\n};\n// Here's the deserialization and the equality check:\nassert_eq!(expected, from_str(hjson).unwrap());\n```\n\n## Known open-source usages\n\n* [Broot](https://dystroy.org/broot) can be configured either with TOML or with Hjson (the selection is dynamic, based on the file extension).\n\n* [lemmy](https://github.com/LemmyNet/lemmy) is configured in Hjson\n\n* [Resc](https://github.com/Canop/resc) can be configured either with JSON or with Hjson\n\n## FAQ\n\n### Does it work with JSON ?\n\nYes as any JSON file can be read as Hjson.\n\n### Why only a derive-based deserializer?\n\nGuessing the types in a format with implicit typing is way too dangereous.\nWhen your user typed `false`, was it a string or a boolean ? When she typed `3`, was it as string or a number ?\nWhile [not as crazy as YAML](https://hitchdev.com/strictyaml/why/implicit-typing-removed/), Hjson has no internal guard for this, and thus should only be deserialized into explicit types.\n\n### Why a deserializer and no serializer?\n\nHjson isn't a data exchange format. It's intended to be written by humans, be full of comments and with a meaningful formatting.\nWhile serializers would make sense in some context, they would have to be template based, or offer other means to specify comments and formatting, and serde isn't the right tool for that.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanop%2Fdeser-hjson","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcanop%2Fdeser-hjson","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanop%2Fdeser-hjson/lists"}