https://github.com/seworqs/json-editor
A dot-notated, chainable JSON editor for PHP with built-in file support and robust array handling.
https://github.com/seworqs/json-editor
array-handling dot-notation editor immutable json json-file json-manipulation json-writer php seworqs
Last synced: 13 days ago
JSON representation
A dot-notated, chainable JSON editor for PHP with built-in file support and robust array handling.
- Host: GitHub
- URL: https://github.com/seworqs/json-editor
- Owner: seworqs
- License: apache-2.0
- Created: 2025-04-12T10:47:58.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-04-27T07:44:32.000Z (9 months ago)
- Last Synced: 2025-10-17T16:28:10.477Z (3 months ago)
- Topics: array-handling, dot-notation, editor, immutable, json, json-file, json-manipulation, json-writer, php, seworqs
- Language: PHP
- Homepage:
- Size: 17.6 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# SEworqs JSON Editor
A dot-notated, chainable JSON editor for PHP with built-in file support and robust array handling.
## Installation
Install via Composer.
```bash
$> composer require seworqs/json-editor
```
## Usage
```php
use Seworqs\Json\JsonEditor;
// Create a new file.
$newJson1 = JsonEditor::createNew("/path/to/save/json/file.json");
// If you want to overwrite a file when it already exists.
$newJson2 = JsonEditor::createNew("/path/to/save/json/file.json", true);
// Create a new file.
$newJson3 = JsonEditor::createFromFile("/path/to/existing/json/file.json");
// Overwrite boolean.
$overwrite = false;
// Add key/value
$newJson3->add('some-key', 'some-value', $overwrite);
// Add key/value in levels deep using dot notation.
$newJson3->add('level1.level2.level3', 'a-deep-value', $overwrite);
// OR Add key/value in levels deep using an array.
$newJson3->add('level1', ['level2' => ['level3' => 'a-deep-level']], $overwrite);
/* Both (using dots or array) will create this:
{
...
"level1": {
"level2": {
"level3": "deep-value"
}
},
...
}
*/
```
> [More examples](docs/Examples.md)
## Features
- [X] Create and edit new JSON file
- [X] Edit existing JSON file
- [X] Use easy dot notation to get to your keys
- [X] Add/delete single or multiple keys at once
- [X] Bump version with seworqs/semver integration
> See our [examples](docs/Examples.md)
## Classes and namespaces
| Namespace | Class | Description |
|--------------------|------------|------------------|
| Seworqs\JsonEditor | JsonEditor | Nice JSON editor |
## License
Apache-2.0, see [LICENSE](./LICENSE)
## About SEworqs
Seworqs builds clean, reusable modules for PHP and Mendix developers.
Learn more at [github.com/seworqs](https://github.com/seworqs)
## Badges
[](https://packagist.org/packages/seworqs/json-editor)
[](https://packagist.org/packages/seworqs/json-editor)
[](https://packagist.org/packages/seworqs/json-editor)
[](https://packagist.org/packages/seworqs/json-editor)
[](https://github.com/seworqs)