https://github.com/ghostwriter/json
Type safe JSON encoder and decoder for PHP
https://github.com/ghostwriter/json
Last synced: 12 months ago
JSON representation
Type safe JSON encoder and decoder for PHP
- Host: GitHub
- URL: https://github.com/ghostwriter/json
- Owner: ghostwriter
- License: other
- Created: 2022-07-11T20:27:44.000Z (almost 4 years ago)
- Default Branch: 3.0.x
- Last Pushed: 2025-06-29T12:19:43.000Z (12 months ago)
- Last Synced: 2025-06-29T13:28:36.851Z (12 months ago)
- Language: PHP
- Size: 614 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Codeowners: .github/CODEOWNERS
- Security: SECURITY.md
Awesome Lists containing this project
README
# Json
[](https://github.com/sponsors/ghostwriter)
[](https://github.com/ghostwriter/json/actions/workflows/automation.yml)
[](https://www.php.net/supported-versions)
[](https://packagist.org/packages/ghostwriter/json)
Safely encode and decode JSON
## Installation
You can install the package via composer:
``` bash
composer require ghostwriter/json
```
### Star ⭐️ this repo if you find it useful
You can also star (🌟) this repo to find it easier later.
## Usage
```php
use \Ghostwriter\Json\Json;
$json = new Json();
$encode = $json->encode(['foo'=>'bar']);
// {"foo":"bar"}
$json->validate($encode); // true
$decode = $json->decode($encode);
// ['foo'=>'bar']
$prettyPrint = true;
$json->encode($decode, $prettyPrint);
// {
// "foo":"bar"
// }
```
### Credits
- [Nathanael Esayeas](https://github.com/ghostwriter)
- [All Contributors](https://github.com/ghostwriter/json/contributors)
### Changelog
Please see [CHANGELOG.md](./CHANGELOG.md) for more information on what has changed recently.
### License
Please see [LICENSE](./LICENSE) for more information on the license that applies to this project.
### Security
Please see [SECURITY.md](./SECURITY.md) for more information on security disclosure process.