{"id":13828479,"url":"https://github.com/adhocore/php-json-comment","last_synced_at":"2025-08-22T08:31:30.651Z","repository":{"id":50135211,"uuid":"100117199","full_name":"adhocore/php-json-comment","owner":"adhocore","description":"Lightweight JSON comment and trailing comma stripper library for PHP with support for literal newlines and nested JSON strings.","archived":false,"fork":false,"pushed_at":"2023-10-11T12:29:01.000Z","size":69,"stargazers_count":31,"open_issues_count":1,"forks_count":6,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-27T13:22:37.114Z","etag":null,"topics":["adhocore","comment","hacktoberfest","human-json","json","json-comment","json5","json5-parser","php","strip-comment"],"latest_commit_sha":null,"homepage":"","language":"PHP","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/adhocore.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","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,"publiccode":null,"codemeta":null},"funding":{"github":"adhocore","custom":["https://paypal.me/ji10"]}},"created_at":"2017-08-12T14:24:40.000Z","updated_at":"2024-03-21T02:26:15.000Z","dependencies_parsed_at":"2024-06-18T15:35:08.175Z","dependency_job_id":"cb43fc6e-3693-4049-a9a1-c282030acd2a","html_url":"https://github.com/adhocore/php-json-comment","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-json-comment","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-json-comment/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-json-comment/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/adhocore%2Fphp-json-comment/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/adhocore","download_url":"https://codeload.github.com/adhocore/php-json-comment/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230575851,"owners_count":18247484,"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":["adhocore","comment","hacktoberfest","human-json","json","json-comment","json5","json5-parser","php","strip-comment"],"created_at":"2024-08-04T09:02:48.597Z","updated_at":"2024-12-20T11:07:55.158Z","avatar_url":"https://github.com/adhocore.png","language":"PHP","readme":"## adhocore/json-comment\n\n[![Latest Version](https://img.shields.io/github/release/adhocore/php-json-comment.svg?style=flat-square)](https://github.com/adhocore/php-json-comment/releases)\n[![Travis Build](https://img.shields.io/travis/adhocore/php-json-comment/main.svg?style=flat-square)](https://travis-ci.org/adhocore/php-json-comment?branch=main)\n[![Scrutinizer CI](https://img.shields.io/scrutinizer/g/adhocore/php-json-comment.svg?style=flat-square)](https://scrutinizer-ci.com/g/adhocore/php-json-comment/?branch=main)\n[![Codecov branch](https://img.shields.io/codecov/c/github/adhocore/php-json-comment/main.svg?style=flat-square)](https://codecov.io/gh/adhocore/php-json-comment)\n[![StyleCI](https://styleci.io/repos/100117199/shield)](https://styleci.io/repos/100117199)\n[![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE)\n[![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=Flexible+JSON+parser+with+comments+and+newline+support+in+PHP\u0026url=https://github.com/adhocore/php-json-comment\u0026hashtags=php,json,flexible-json,json-comment)\n[![Support](https://img.shields.io/static/v1?label=Support\u0026message=%E2%9D%A4\u0026logo=GitHub)](https://github.com/sponsors/adhocore)\n\u003c!-- [![Donate 15](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square\u0026label=donate+15)](https://www.paypal.me/ji10/15usd)\n[![Donate 25](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square\u0026label=donate+25)](https://www.paypal.me/ji10/25usd)\n[![Donate 50](https://img.shields.io/badge/donate-paypal-blue.svg?style=flat-square\u0026label=donate+50)](https://www.paypal.me/ji10/50usd) --\u003e\n\n\n- Lightweight JSON comment stripper library for PHP.\n- Makes possible to have comment in any form of JSON data.\n- Supported comments: single line `// comment` or multi line `/* comment */`.\n- Also strips trailing comma at the end of array or object, eg:\n    - `[1,2,,]` =\u003e `[1,2]`\n    - `{\"x\":1,,}` =\u003e `{\"x\":1}`\n- Handles literal LF (newline/linefeed) within string notation so that we can have multiline string\n- Supports JSON string inside JSON string (see ticket [#15](https://github.com/adhocore/php-json-comment/issues/15) and PR [#16](https://github.com/adhocore/php-json-comment/pull/16))\n- Zero dependency (no vendor bloat).\n\n## Installation\n```bash\ncomposer require adhocore/json-comment\n\n# for php5.6\ncomposer require adhocore/json-comment:^0.2\n```\n\n## Usage\n```php\nuse Ahc\\Json\\Comment;\n\n// The JSON string!\n$someJsonText = '{\"a\":1,\n\"b\":2,// comment\n\"c\":3 /* inline comment */,\n// comment\n\"d\":/* also a comment */\"d\",\n/* creepy comment*/\"e\":2.3,\n/* multi line\ncomment */\n\"f\":\"f1\",}';\n\n// OR\n$someJsonText = file_get_contents('...');\n\n// Strip only!\n(new Comment)-\u003estrip($someJsonText);\n\n// Strip and decode!\n(new Comment)-\u003edecode($someJsonText);\n\n// You can pass args like in `json_decode`\n(new Comment)-\u003edecode($someJsonText, $assoc = true, $depth = 512, $options = JSON_BIGINT_AS_STRING);\n\n// Or you can use static alias of decode:\nComment::parse($json, true);\n\n# Or use file directly\nComment::parseFromFile('/path/to/file.json', true);\n```\n\n### Example\n\nAn example JSON that this library can parse:\n\n```json\n{\n  \"name\": \"adhocore/json-comment\",\n  \"description\": \"JSON comment stripper library for PHP.\n    There is literal line break just above this line but that's okay\",\n  \"type\":/* This is creepy comment */ \"library\",\n  \"keywords\": [\n    \"json\",\n    \"comment\",\n    // Single line comment, Notice the comma below:\n    \"strip-comment\",\n  ],\n  \"license\": \"MIT\",\n  /*\n   * This is a multiline\n   * comment.\n   */\n  \"authors\": [\n    {\n      \"name\": \"Jitendra Adhikari\",\n      \"email\": \"jiten.adhikary@gmail.com\",\n    },\n  ],\n  \"autoload\": {\n      \"psr-4\": {\n          \"Ahc\\\\Json\\\\\": \"src/\",\n      },\n  },\n  \"autoload-dev\": {\n      \"psr-4\": {\n          \"Ahc\\\\Json\\\\Test\\\\\": \"tests/\",\n      },\n  },\n  \"require\": {\n      \"php\": \"\u003e=7.0\",\n      \"ext-ctype\": \"*\",\n  },\n  \"require-dev\": {\n      \"phpunit/phpunit\": \"^6.5 || ^7.5 || ^8.5\",\n  },\n  \"scripts\": {\n      \"test\": \"phpunit\",\n      \"echo\": \"echo '// This is not comment'\",\n      \"test:cov\": \"phpunit --coverage-text\",\n  },\n}\n```\n","funding_links":["https://github.com/sponsors/adhocore","https://paypal.me/ji10","https://www.paypal.me/ji10/15usd","https://www.paypal.me/ji10/25usd","https://www.paypal.me/ji10/50usd"],"categories":["PHP"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadhocore%2Fphp-json-comment","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fadhocore%2Fphp-json-comment","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fadhocore%2Fphp-json-comment/lists"}