{"id":16856400,"url":"https://github.com/vallentin/jsonc-to-json","last_synced_at":"2025-04-11T07:39:03.494Z","repository":{"id":183112435,"uuid":"657575572","full_name":"vallentin/jsonc-to-json","owner":"vallentin","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-27T05:04:23.000Z","size":12,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-03T18:07:26.414Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/vallentin.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,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-06-23T11:14:05.000Z","updated_at":"2025-01-25T09:51:07.000Z","dependencies_parsed_at":null,"dependency_job_id":"b3670479-2de1-4d44-89aa-e077b2ee090d","html_url":"https://github.com/vallentin/jsonc-to-json","commit_stats":null,"previous_names":["vallentin/jsonc-to-json"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fjsonc-to-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fjsonc-to-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fjsonc-to-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vallentin%2Fjsonc-to-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vallentin","download_url":"https://codeload.github.com/vallentin/jsonc-to-json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239576656,"owners_count":19662109,"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":[],"created_at":"2024-10-13T14:04:07.996Z","updated_at":"2025-02-19T00:31:52.337Z","avatar_url":"https://github.com/vallentin.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# jsonc-to-json\n\n[![CI](https://github.com/vallentin/jsonc-to-json/workflows/CI/badge.svg)](https://github.com/vallentin/jsonc-to-json/actions?query=workflow%3ACI)\n[![Latest Version](https://img.shields.io/crates/v/jsonc-to-json.svg)](https://crates.io/crates/jsonc-to-json)\n[![Docs](https://docs.rs/jsonc-to-json/badge.svg)](https://docs.rs/jsonc-to-json)\n[![License](https://img.shields.io/github/license/vallentin/jsonc-to-json.svg)](https://github.com/vallentin/jsonc-to-json)\n\n\u003c!-- cargo-rdme start --\u003e\n\nSimple library for converting [JSON with Comments] into [JSON],\nin short it removes the following:\n\n- Line comments, e.g. `// Line Comment`\n- Block comments, e.g. `/* Block Comment */`\n- Trailing commas, e.g. `[1,2,3,,]` -\u003e `[1,2,3]`\n\n**Note:** The implementation does not use a full-blown [JSON with Comments]\nparser. Instead it uses a [JSON with Comments] tokenizer, which makes\nconversion a lot faster.\n\n_Currently `#![no_std]` is not supported. It will however be added, when\nsome upstream changes have been applied._\n\nSee [`jsonc_to_json()`] for more information.\n\n## Example\n\n```rust\nuse jsonc_to_json::{jsonc_to_json, jsonc_to_json_into};\n\nlet jsonc = \"{\\\"arr\\\": [1, 2,/* Comment */ 3, 4,,]}// Line Comment\";\n\nlet json = jsonc_to_json(jsonc);\nprintln!(\"{}\", json);\n\n// Alternatively, use `jsonc_to_json_into()` to reuse an\n// already allocated `String`\nlet mut json = String::new();\njsonc_to_json_into(jsonc, \u0026mut json);\nprintln!(\"{}\", json);\n```\n\nBoth output the following:\n\n```text\n{\"arr\": [1, 2, 3, 4]}\n```\n\n## Serde Example\n\n```rust\nuse jsonc_to_json::{jsonc_to_json, jsonc_to_json_into};\nuse serde::Deserialize;\n\n#[derive(Deserialize, Debug)]\nstruct Data {\n    arr: Vec\u003ci32\u003e,\n}\nlet jsonc = \"{\\\"arr\\\": [1, 2,/* Comment */ 3, 4,,]}// Line Comment\";\n\nlet json = jsonc_to_json(jsonc);\nlet data: Data = serde_json::from_str(\u0026json)?;\n\nprintln!(\"{}\", json);\nprintln!(\"{:?}\", data);\n```\n\nWhich outputs the following:\n\n```text\n{\"arr\": [1, 2, 3, 4]}\nData { arr: [1, 2, 3, 4] }\n```\n\n## Non-Allocating \u0026 Zero-Copy Iterator Example\n\nNon-allocating [`Iterator`] that yields string slices of\nvalid [JSON].\n\n```rust\nuse jsonc_to_json::jsonc_to_json_iter;\n\nlet jsonc = r#\"{foo}/**/[1,2,3,,]\"bar\"\"#;\n\nlet mut iter = jsonc_to_json_iter(jsonc);\nassert_eq!(iter.next(), Some(\"{foo}\")); // Line comment was removed\nassert_eq!(iter.next(), Some(\"[1,2,3\")); // Trailing commas was removed\nassert_eq!(iter.next(), Some(\"]\\\"bar\\\"\"));\nassert_eq!(iter.next(), None);\n```\n\n[JSON with Comments]: https://code.visualstudio.com/docs/languages/json#_json-with-comments\n[JSON]: https://www.json.org/json-en.html\n\n\u003c!-- cargo-rdme end --\u003e\n\n[`jsonc_to_json()`]: https://docs.rs/jsonc-to-json/*/jsonc_to_json/fn.jsonc_to_json.html\n[`Iterator`]: https://doc.rust-lang.org/std/iter/trait.Iterator.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallentin%2Fjsonc-to-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvallentin%2Fjsonc-to-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvallentin%2Fjsonc-to-json/lists"}