{"id":13439318,"url":"https://github.com/maciejhirsz/json-rust","last_synced_at":"2025-05-14T20:08:08.208Z","repository":{"id":9125981,"uuid":"60961783","full_name":"maciejhirsz/json-rust","owner":"maciejhirsz","description":"JSON implementation in Rust","archived":false,"fork":false,"pushed_at":"2024-04-14T07:19:58.000Z","size":611,"stargazers_count":575,"open_issues_count":62,"forks_count":64,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-04-13T15:59:03.356Z","etag":null,"topics":["decoder","encoder","json","parser","rust"],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maciejhirsz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE-APACHE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-12T10:39:47.000Z","updated_at":"2025-04-09T00:01:09.000Z","dependencies_parsed_at":"2024-06-18T15:21:36.935Z","dependency_job_id":"b672af57-1ce7-4c13-bc21-a0dbef279d84","html_url":"https://github.com/maciejhirsz/json-rust","commit_stats":{"total_commits":243,"total_committers":20,"mean_commits":12.15,"dds":0.1728395061728395,"last_synced_commit":"0775592d339002ab148185264970c2a6e30b5d37"},"previous_names":[],"tags_count":38,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maciejhirsz%2Fjson-rust","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maciejhirsz%2Fjson-rust/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maciejhirsz%2Fjson-rust/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maciejhirsz%2Fjson-rust/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maciejhirsz","download_url":"https://codeload.github.com/maciejhirsz/json-rust/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254219373,"owners_count":22034397,"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":["decoder","encoder","json","parser","rust"],"created_at":"2024-07-31T03:01:12.897Z","updated_at":"2025-05-14T20:08:08.155Z","avatar_url":"https://github.com/maciejhirsz.png","language":"Rust","funding_links":[],"categories":["Libraries","Rust","库 Libraries","库"],"sub_categories":["Encoding","编码 Encoding","编码(Encoding)","加密 Encoding"],"readme":"![](https://raw.githubusercontent.com/maciejhirsz/json-rust/master/json-rust-logo-small.png)\n\n# json-rust\n\nParse and serialize [JSON](http://json.org/) with ease.\n\n**[Changelog](https://github.com/maciejhirsz/json-rust/releases) -**\n**[Complete Documentation](https://docs.rs/json/) -**\n**[Cargo](https://crates.io/crates/json) -**\n**[Repository](https://github.com/maciejhirsz/json-rust)**\n\n## Why?\n\nJSON is a very loose format where anything goes - arrays can hold mixed\ntypes, object keys can change types between API calls or not include\nsome keys under some conditions. Mapping that to idiomatic Rust structs\nintroduces friction.\n\nThis crate intends to avoid that friction.\n\n```rust\nlet parsed = json::parse(r#\"\n\n{\n    \"code\": 200,\n    \"success\": true,\n    \"payload\": {\n        \"features\": [\n            \"awesome\",\n            \"easyAPI\",\n            \"lowLearningCurve\"\n        ]\n    }\n}\n\n\"#).unwrap();\n\nlet instantiated = object!{\n    // quotes on keys are optional\n    \"code\": 200,\n    success: true,\n    payload: {\n        features: [\n            \"awesome\",\n            \"easyAPI\",\n            \"lowLearningCurve\"\n        ]\n    }\n};\n\nassert_eq!(parsed, instantiated);\n```\n\n## First class citizen\n\nUsing macros and indexing, it's easy to work with the data.\n\n```rust\nlet mut data = object!{\n    foo: false,\n    bar: null,\n    answer: 42,\n    list: [null, \"world\", true]\n};\n\n// Partial equality is implemented for most raw types:\nassert!(data[\"foo\"] == false);\n\n// And it's type aware, `null` and `false` are different values:\nassert!(data[\"bar\"] != false);\n\n// But you can use any Rust number types:\nassert!(data[\"answer\"] == 42);\nassert!(data[\"answer\"] == 42.0);\nassert!(data[\"answer\"] == 42isize);\n\n// Access nested structures, arrays and objects:\nassert!(data[\"list\"][0].is_null());\nassert!(data[\"list\"][1] == \"world\");\nassert!(data[\"list\"][2] == true);\n\n// Error resilient - accessing properties that don't exist yield null:\nassert!(data[\"this\"][\"does\"][\"not\"][\"exist\"].is_null());\n\n// Mutate by assigning:\ndata[\"list\"][0] = \"Hello\".into();\n\n// Use the `dump` method to serialize the data:\nassert_eq!(data.dump(), r#\"{\"foo\":false,\"bar\":null,\"answer\":42,\"list\":[\"Hello\",\"world\",true]}\"#);\n\n// Or pretty print it out:\nprintln!(\"{:#}\", data);\n```\n\n## Installation\n\nJust add it to your `Cargo.toml` file:\n\n```toml\n[dependencies]\njson = \"*\"\n```\n\nThen import it in your `main.rs` / `lib.rs` file:\n\n```rust\n#[macro_use]\nextern crate json;\n```\n\n## Performance and Conformance\n\nThere used to be a statement here saying that performance is not the main goal of this\ncrate. It is definitely one of them now.\n\nWhile this crate doesn't provide a way to parse JSON to native Rust structs, it does a\nlot to optimize its performance for DOM parsing, stringifying and manipulation. It does\n[very well in benchmarks](https://github.com/serde-rs/json-benchmark), in some cases it\ncan even outperform parsing to structs.\n\nThis crate implements the standard according to the [\nRFC 7159](https://tools.ietf.org/html/rfc7159) and\n[ECMA-404](http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-404.pdf)\ndocuments. For the best interoperability numbers are treated stored as 64bit precision\nmantissa with 16 bit decimal exponent for floating point representation.\n\n## License\n\nThis crate is distributed under the terms of both the MIT license\nand the Apache License (Version 2.0). Choose whichever one works best for you.\n\nSee [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaciejhirsz%2Fjson-rust","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaciejhirsz%2Fjson-rust","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaciejhirsz%2Fjson-rust/lists"}