{"id":20180546,"url":"https://github.com/ergebnis/json-printer","last_synced_at":"2025-05-15T22:11:59.733Z","repository":{"id":28098332,"uuid":"116250188","full_name":"ergebnis/json-printer","owner":"ergebnis","description":"📃 Provides a composer package with a JSON printer, allowing for flexible indentation.","archived":false,"fork":false,"pushed_at":"2025-04-15T11:13:07.000Z","size":8223,"stargazers_count":87,"open_issues_count":2,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-15T12:25:24.275Z","etag":null,"topics":["formatter","json","printer"],"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/ergebnis.png","metadata":{"funding":{"github":["ergebnis","localheinz"]},"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-01-04T11:05:15.000Z","updated_at":"2025-04-15T11:13:10.000Z","dependencies_parsed_at":"2023-12-08T09:26:20.705Z","dependency_job_id":"3729247c-e6eb-46f0-aa44-7908a38d4501","html_url":"https://github.com/ergebnis/json-printer","commit_stats":{"total_commits":576,"total_committers":4,"mean_commits":144.0,"dds":"0.43229166666666663","last_synced_commit":"8e60ce1e79b2a6b3c74750847b89c5eb7aed6032"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergebnis%2Fjson-printer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergebnis%2Fjson-printer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergebnis%2Fjson-printer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ergebnis%2Fjson-printer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ergebnis","download_url":"https://codeload.github.com/ergebnis/json-printer/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254430331,"owners_count":22069909,"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":["formatter","json","printer"],"created_at":"2024-11-14T02:31:42.848Z","updated_at":"2025-05-15T22:11:54.724Z","avatar_url":"https://github.com/ergebnis.png","language":"PHP","readme":"# json-printer\n\n[![Integrate](https://github.com/ergebnis/json-printer/workflows/Integrate/badge.svg)](https://github.com/ergebnis/json-printer/actions)\n[![Merge](https://github.com/ergebnis/json-printer/workflows/Merge/badge.svg)](https://github.com/ergebnis/json-printer/actions)\n[![Release](https://github.com/ergebnis/json-printer/workflows/Release/badge.svg)](https://github.com/ergebnis/json-printer/actions)\n[![Renew](https://github.com/ergebnis/json-printer/workflows/Renew/badge.svg)](https://github.com/ergebnis/json-printer/actions)\n\n[![Code Coverage](https://codecov.io/gh/ergebnis/json-printer/branch/main/graph/badge.svg)](https://codecov.io/gh/ergebnis/json-printer)\n\n[![Latest Stable Version](https://poser.pugx.org/ergebnis/json-printer/v/stable)](https://packagist.org/packages/ergebnis/json-printer)\n[![Total Downloads](https://poser.pugx.org/ergebnis/json-printer/downloads)](https://packagist.org/packages/ergebnis/json-printer)\n[![Monthly Downloads](http://poser.pugx.org/ergebnis/json-printer/d/monthly)](https://packagist.org/packages/ergebnis/json-printer)\n\nThis project provides a [`composer`](https://getcomposer.org) package with a JSON printer, allowing for flexible indentation.\n\n## Installation\n\nRun\n\n```sh\ncomposer require ergebnis/json-printer\n```\n\n## Usage\n\nLet's assume we have a variable `$json` which contains some JSON that is not indented:\n\n```json\n{\"name\":\"Andreas Möller\",\"emoji\":\"🤓\",\"urls\":[\"https://localheinz.com\",\"https://github.com/localheinz\",\"https://twitter.com/localheinz\"]}\n```\n\nor indented with 4 spaces:\n\n```json\n{\n    \"name\":\"Andreas Möller\",\n    \"emoji\":\"🤓\",\n    \"urls\":[\n        \"https://localheinz.com\",\n        \"https://github.com/localheinz\",\n        \"https://twitter.com/localheinz\"\n    ]\n}\n```\n\nbut we want to indent it with 2 spaces (or tabs).\n\nThis is where `Ergebnis\\Json\\Printer\\Printer` comes in\n\n```php\n\u003c?php\n\ndeclare(strict_types=1);\n\nuse Ergebnis\\Json\\Printer;\n\n$printer = new Printer\\Printer();\n\n$printed = $printer-\u003eprint(\n    $json,\n    '  ',\n);\n```\n\nwhich results in `$printed`:\n\n```json\n{\n  \"name\":\"Andreas Möller\",\n  \"emoji\":\"🤓\",\n  \"urls\":[\n    \"https://localheinz.com\",\n    \"https://github.com/localheinz\",\n    \"https://twitter.com/localheinz\"\n  ]\n}\n```\n\n:bulb: Note that this printer is only concerned with normalizing the indentation, no escaping or un-escaping occurs.\n\n## Changelog\n\nThe maintainers of this project record notable changes to this project in a [changelog](CHANGELOG.md).\n\n## Contributing\n\nThe maintainers of this project suggest following the [contribution guide](.github/CONTRIBUTING.md).\n\n## Code of Conduct\n\nThe maintainers of this project ask contributors to follow the [code of conduct](https://github.com/ergebnis/.github/blob/main/CODE_OF_CONDUCT.md).\n\n## General Support Policy\n\nThe maintainers of this project provide limited support.\n\nYou can support the maintenance of this project by [sponsoring @localheinz](https://github.com/sponsors/localheinz) or [requesting an invoice for services related to this project](mailto:am@localheinz.com?subject=ergebnis/json-printer:%20Requesting%20invoice%20for%20services).\n\n## PHP Version Support Policy\n\nThis project supports PHP versions with [active and security support](https://www.php.net/supported-versions.php).\n\nThe maintainers of this project add support for a PHP version following its initial release and drop support for a PHP version when it has reached the end of security support.\n\n## Security Policy\n\nThis project has a [security policy](.github/SECURITY.md).\n\n## License\n\nThis project uses the [MIT license](LICENSE.md).\n\n## Credits\n\nThe [`Printer`](src/Printer.php) is adopted from [`Composer\\Json\\JsonFormatter`](https://github.com/composer/composer/blob/1.6.0/src/Composer/Json/JsonFormatter.php) (originally licensed under MIT by [Nils Adermann](https://github.com/naderman) and [Jordi Boggiano](https://github.com/seldaek)), who adopted it from a [blog post by Dave Perrett](https://www.daveperrett.com/articles/2008/03/11/format-json-with-php/) (originally licensed under MIT by [Dave Perrett](https://github.com/recurser)).\n\nThe [`PrinterTest`](test/Unit/PrinterTest.php) is inspired by [`Composer\\Test\\Json\\JsonFormatterTest`](https://github.com/composer/composer/blob/1.6.0/tests/Composer/Test/Json/JsonFormatterTest.php) (originally licensed under MIT by [Nils Adermann](https://github.com/naderman) and [Jordi Boggiano](https://github.com/seldaek)), as well as [`ZendTest\\Json\\JsonTest`](https://github.com/zendframework/zend-json/blob/release-3.0.0/test/JsonTest.php) (originally licensed under New BSD License).\n\n## Social\n\nFollow [@localheinz](https://twitter.com/intent/follow?screen_name=localheinz) and [@ergebnis](https://twitter.com/intent/follow?screen_name=ergebnis) on Twitter.\n","funding_links":["https://github.com/sponsors/ergebnis","https://github.com/sponsors/localheinz"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fergebnis%2Fjson-printer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fergebnis%2Fjson-printer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fergebnis%2Fjson-printer/lists"}