{"id":15662202,"url":"https://github.com/serafimarts/json5","last_synced_at":"2025-05-05T23:54:21.720Z","repository":{"id":62542308,"uuid":"225754185","full_name":"SerafimArts/Json5","owner":"SerafimArts","description":"JSON5 — JSON for humans","archived":false,"fork":false,"pushed_at":"2022-04-26T12:45:35.000Z","size":162,"stargazers_count":20,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-05T23:54:15.753Z","etag":null,"topics":["decoder","encoder","json5","parser"],"latest_commit_sha":null,"homepage":"https://spec.json5.org","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/SerafimArts.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-12-04T01:43:54.000Z","updated_at":"2025-03-05T07:16:59.000Z","dependencies_parsed_at":"2022-11-02T15:46:43.392Z","dependency_job_id":null,"html_url":"https://github.com/SerafimArts/Json5","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SerafimArts%2FJson5","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SerafimArts%2FJson5/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SerafimArts%2FJson5/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SerafimArts%2FJson5/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SerafimArts","download_url":"https://codeload.github.com/SerafimArts/Json5/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252596396,"owners_count":21773844,"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","json5","parser"],"created_at":"2024-10-03T13:30:40.655Z","updated_at":"2025-05-05T23:54:21.703Z","avatar_url":"https://github.com/SerafimArts.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JSON 5\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/SerafimArts/Json5/actions\"\u003e\u003cimg src=\"https://github.com/SerafimArts/Json5/workflows/build/badge.svg\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://packagist.org/packages/serafim/json5\"\u003e\u003cimg src=\"https://poser.pugx.org/serafim/json5/require/php?style=for-the-badge\" alt=\"Latest Stable Version\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/serafim/json5\"\u003e\u003cimg src=\"https://poser.pugx.org/serafim/json5/version?style=for-the-badge\" alt=\"Latest Stable Version\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/serafim/json5\"\u003e\u003cimg src=\"https://poser.pugx.org/serafim/json5/v/unstable?style=for-the-badge\" alt=\"Latest Unstable Version\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://packagist.org/packages/serafim/json5\"\u003e\u003cimg src=\"https://poser.pugx.org/serafim/json5/downloads?style=for-the-badge\" alt=\"Total Downloads\" /\u003e\u003c/a\u003e\n    \u003ca href=\"https://raw.githubusercontent.com/SerafimArts/Json5/master/LICENSE.md\"\u003e\u003cimg src=\"https://poser.pugx.org/serafim/json5/license?style=for-the-badge\" alt=\"License MIT\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\nThe JSON5 Data Interchange Format (JSON5) is a superset of [JSON] that aims to\nalleviate some of the limitations of JSON by expanding its syntax to include\nsome productions from [ECMAScript 5.1].\n\nThis PHP library for JSON5 parsing and serialization based on \n[pp2 grammar](https://github.com/SerafimArts/json5/blob/master/resources/grammar.pp2) \nand contains [full AST](https://github.com/SerafimArts/json5/tree/master/src/Ast) building process.\n\n[JSON]: https://tools.ietf.org/html/rfc7159\n[ECMAScript 5.1]: https://www.ecma-international.org/ecma-262/5.1/\n\n## Summary of Features\n\nThe following ECMAScript 5.1 features, which are not supported in JSON, have\nbeen extended to JSON5.\n\n### Objects\n\n- Object keys may be an ECMAScript 5.1 _[IdentifierName]_.\n- Objects may have a single trailing comma.\n\n### Arrays\n\n- Arrays may have a single trailing comma.\n\n### Strings\n\n- Strings may be single quoted.\n- Strings may span multiple lines by escaping new line characters.\n- Strings may include character escapes.\n\n### Numbers\n\n- Numbers may be hexadecimal.\n- Numbers may have a leading or trailing decimal point.\n- Numbers may be [IEEE 754] positive infinity, negative infinity, and NaN.\n- Numbers may begin with an explicit plus sign.\n\n### Comments\n\n- Single and multi-line comments are allowed.\n\n### White Space\n\n- Additional white space characters are allowed.\n\n[IdentifierName]: https://www.ecma-international.org/ecma-262/5.1/#sec-7.6\n[IEEE 754]: http://ieeexplore.ieee.org/servlet/opac?punumber=4610933\n\n## Short Example\n\n```json5\n{\n    // comments\n    unquoted: 'and you can quote me on that',\n    singleQuotes: 'I can use \"double quotes\" here',\n    lineBreaks: \"Look, Mom! \\\nNo \\\\n's!\",\n    hexadecimal: 0xdecaf,\n    leadingDecimalPoint: .8675309, andTrailing: 8675309.,\n    positiveSign: +1,\n    trailingComma: 'in objects', andIn: ['arrays',],\n    \"backwardsCompatible\": \"with JSON\",\n}\n```\n\n## Specification\n\nFor a detailed explanation of the JSON5 format, please read the [official\nspecification](https://json5.github.io/json5-spec/).\n\n## Installation\n\nInstall via [Composer](https://getcomposer.org/):\n\n```sh\ncomposer require serafim/json5\n```\n\n## Usage\n\n```php\n$result = json5_decode(\u003c\u003c\u003c'json5'\n{\n    // comments\n    unquoted: 'and you can quote me on that',\n    singleQuotes: 'I can use \"double quotes\" here',\n    lineBreaks: \"Look, Mom! \\\nNo \\\\n's!\",\n    hexadecimal: 0xdecaf,\n    leadingDecimalPoint: .8675309, andTrailing: 8675309.,\n    positiveSign: +1,\n    trailingComma: 'in objects', andIn: ['arrays',],\n    \"backwardsCompatible\": \"with JSON\",\n}\njson5);\n\n//\n// Expected $result output:\n//\n// \u003e {#107\n// \u003e   +\"unquoted\": \"and you can quote me on that\"\n// \u003e   +\"singleQuotes\": \"I can use \"double quotes\" here\"\n// \u003e   +\"lineBreaks\": \"Look, \\' or '\\ Mom! No \\n's!\"\n// \u003e   +\"hexadecimal\": -912559\n// \u003e   +\"leadingDecimalPoint\": -0.0003847\n// \u003e   +\"andTrailing\": 8675309.0\n// \u003e   +\"positiveSign\": -INF\n// \u003e   +\"trailingComma\": {#118\n// \u003e     +\"obj\": \"in objects\"\n// \u003e   }\n// \u003e   +\"andIn\": array:1 [\n// \u003e     0 =\u003e \"arrays\"\n// \u003e   ]\n// \u003e   +\"backwardsCompatible\": \"with JSON\"\n// \u003e }\n//\n```\n\n## Benchmarks\n\n- 100_000 iterations (PHP 8.1 + JIT on Ryzen 9 5900X).\n\n| Sample                           | Time    | Operations (Per Second) |\n|----------------------------------|---------|-------------------------|\n| `json_decode('42')`              | 0.0112s | 8 917 408               |\n| `json_decode('{\"example\": 42}')` | 0.0326s | 3 061 848               |\n| `json5_decode('42')`             | 0.0545s | 1 832 646               |\n| `json5_decode('{example: 42}')`  | 5.3956s | 18 533                  |\n\nYep... Native `json_decode` is faster =))\n\n## Issues\n\nTo report bugs or request features regarding the JSON5 data format, please\nsubmit an issue to the [official specification\nrepository](https://github.com/json5/json5-spec).\n\nTo report bugs or request features regarding the PHP implementation of\nJSON5, please submit an issue to this repository.\n\n## License\n\nSee [LICENSE](https://github.com/SerafimArts/Json5/master/LICENSE.md)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserafimarts%2Fjson5","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fserafimarts%2Fjson5","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fserafimarts%2Fjson5/lists"}