{"id":27376293,"url":"https://github.com/julesguesnon/spanned-json-parser","last_synced_at":"2025-04-13T12:36:16.425Z","repository":{"id":204086958,"uuid":"710894579","full_name":"JulesGuesnon/spanned-json-parser","owner":"JulesGuesnon","description":"🔨 A JSON parser that will return span information","archived":false,"fork":false,"pushed_at":"2023-11-11T02:47:12.000Z","size":4534,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T12:16:17.594Z","etag":null,"topics":["json","parser","rust","span"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/spanned_json_parser","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/JulesGuesnon.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2023-10-27T17:05:34.000Z","updated_at":"2024-08-02T15:31:28.000Z","dependencies_parsed_at":"2023-11-08T08:58:12.390Z","dependency_job_id":null,"html_url":"https://github.com/JulesGuesnon/spanned-json-parser","commit_stats":null,"previous_names":["julesguesnon/spanned-json-parser"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JulesGuesnon%2Fspanned-json-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JulesGuesnon%2Fspanned-json-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JulesGuesnon%2Fspanned-json-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JulesGuesnon%2Fspanned-json-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JulesGuesnon","download_url":"https://codeload.github.com/JulesGuesnon/spanned-json-parser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248715210,"owners_count":21150061,"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":["json","parser","rust","span"],"created_at":"2025-04-13T12:36:15.093Z","updated_at":"2025-04-13T12:36:16.410Z","avatar_url":"https://github.com/JulesGuesnon.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spanned Json Parser \u0026emsp; [![Build Status]][actions] [![Latest Version]][crates.io]\n\n[Build Status]: https://img.shields.io/github/actions/workflow/status/julesguesnon/spanned-json-parser/rust.yml?branch=main\n[actions]: https://github.com/julesguesnon/spanned-json-parser/actions?query=branch%3Amain\n[crates.io]: https://crates.io/crates/spanned_json_parser\n[Latest Version]: https://img.shields.io/crates/v/spanned_json_parser.svg\n\nThis crate is a json parser that will return span information for values, which mean lines and column number. It is also compatible with [serde](https://serde.rs/) so you can serialize it to any other struct that implements [Deserialize](https://docs.rs/serde/latest/serde/de/trait.Deserialize.html)\n\n## Why use it ?\n\nOne of the main use case is to do validation after parsing. By having the line and col number, you can tell really precisely to a user where a value is invalid\n\n## How to use it ?\n\nThe crate expose a [`Value`](https://docs.rs/spanned_json_parser/0.2.0/spanned_json_parser/value/enum.Value.html) that is similar to [serde](https://docs.rs/serde_json/latest/serde_json/value/enum.Value.html), and wraps everything into this struct:\n\n```rust\npub struct Position {\n    pub col: usize,\n    pub line: usize,\n}\n\npub struct SpannedValue {\n    pub value: Value,\n    pub start: Position,\n    pub end: Position,\n}\n```\n\n### Parsing\n\n```rust\nuse spanned_json_parse::parse;\nuse std::fs;\n\nfn main() {\n    let json = fs::read_to_string(path).unwrap();\n\n    let parsed = parse(\u0026json);\n\n    println!(\"Parsed: {:#?}\", parsed);\n}\n```\n\n### Serializing in a struct\n\n```rust\nuse serde::Deserialize;\nuse spanned_json_parser::parse;\n\n#[derive(Deserialize)]\nstruct Test {\n    pub hello: String,\n}\n\nfn main() {\n    let json = r#\"{\"hello\": \"world\"}\"#;\n\n    let parsed = parse(json).unwrap();\n\n    let test: Test = serde_json::from_value(serde_json::to_value(parsed).unwrap()).unwrap();\n\n    println!(\"Test hello: {}\", test.hello);\n}\n```\n\n## Performance\n\nHere are the outputs of the benchmark. Everything was tested on a Macbook Pro M1, so keep in mind that this numbers are here to give you an idea of the performance, but might not be representative of the reality:\n\n```\nParser ./benches/data/twitter.json\ntime:   [10.220 ms 10.279 ms 10.334 ms]\nthrpt:  [58.280 MiB/s 58.589 MiB/s 58.932 MiB/s]\n\nParser ./benches/data/citm_catalog.json\ntime:   [18.204 ms 18.281 ms 18.353 ms]\nthrpt:  [89.752 MiB/s 90.102 MiB/s 90.486 MiB/s]\n\nParser ./benches/data/canada.json\ntime:   [42.026 ms 42.188 ms 42.341 ms]\nthrpt:  [50.702 MiB/s 50.886 MiB/s 51.082 MiB/s]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulesguesnon%2Fspanned-json-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjulesguesnon%2Fspanned-json-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjulesguesnon%2Fspanned-json-parser/lists"}