{"id":27958329,"url":"https://github.com/91ahmed/jsonmodifier","last_synced_at":"2025-05-07T18:22:11.721Z","repository":{"id":65538270,"uuid":"586768506","full_name":"91ahmed/JsonModifier","owner":"91ahmed","description":"JsonModifier - a PHP package allows developers to manipulate JSON files by performing data lookup and many other operations such as read, add, delete and update.  🐘 ","archived":false,"fork":false,"pushed_at":"2023-04-19T05:57:09.000Z","size":40,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-09-25T05:14:35.509Z","etag":null,"topics":["json","json-parser","php"],"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/91ahmed.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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}},"created_at":"2023-01-09T07:23:56.000Z","updated_at":"2024-09-13T10:20:13.000Z","dependencies_parsed_at":"2025-01-25T07:21:05.220Z","dependency_job_id":"b18a5286-e807-4e35-ad1b-fa9d8e493101","html_url":"https://github.com/91ahmed/JsonModifier","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/91ahmed%2FJsonModifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/91ahmed%2FJsonModifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/91ahmed%2FJsonModifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/91ahmed%2FJsonModifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/91ahmed","download_url":"https://codeload.github.com/91ahmed/JsonModifier/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252931825,"owners_count":21827175,"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":["json","json-parser","php"],"created_at":"2025-05-07T18:22:10.976Z","updated_at":"2025-05-07T18:22:11.675Z","avatar_url":"https://github.com/91ahmed.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# JsonModifier\n\n**JsonModifier** is a PHP package designed to assist developers in manipulating JSON files. It offers a range of operations, including data lookup, reading, adding, deleting, and updating JSON data.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Retrieving Data](#retrieving-data)\n  - [Updating Data](#updating-data)\n  - [Adding Data](#adding-data)\n  - [Searching Data](#searching-data)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Installation\n\nInstall the package via Composer:\n\n```bash\ncomposer require jsonmodifier/json\n```\n\n## Usage\n\nFirst, include the Composer autoload file and create a new instance of `JsonModifier` by providing the path to your JSON file:\n\n```php\nrequire 'vendor/autoload.php';\n\nuse PhpJsonModifier\\JsonModifier;\n\n$json = new JsonModifier('path/to/your/jsonfile.json');\n```\n\n### Retrieving Data\n\nTo retrieve all data from a specific index:\n\n```php\n$data = $json-\u003eindex('items')-\u003eget();\n```\n\n### Updating Data\n\nTo update specific fields where a condition is met:\n\n```php\n$update = $json-\u003eindex('items')-\u003eupdate(\n    ['id', '3'], // Condition: WHERE id = 3\n    [\n        ['unitprice' =\u003e '224.50'],\n        ['color' =\u003e '#fff']\n    ]\n);\n```\n\n### Adding Data\n\nTo add a new item to the JSON file:\n\n```php\n$add = $json-\u003eindex('items')-\u003eadd([\n    \"id\" =\u003e \"10\",\n    \"name\" =\u003e \"black shirt\",\n    \"unitprice\" =\u003e \"150.00\"\n]);\n```\n\n### Searching Data\n\nTo search for items matching specific criteria:\n\n```php\n$search = $json-\u003eindex('items')-\u003esearch(['id' =\u003e '2'])-\u003eget();\n```\n\nTo retrieve the first item that matches the criteria:\n\n```php\n$search = $json-\u003eindex('items')-\u003esearch(['id' =\u003e '2'])-\u003efirst();\n```\n\n## Contributing\n\nContributions are welcome! Please fork the repository and submit a pull request with your proposed changes. Ensure that your code adheres to the project's coding standards and includes appropriate tests.\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n\n---\n\n*Note: Ensure that your JSON files are properly formatted to prevent errors. Here's an example of a valid JSON structure:*\n\n```json\n[\n    {\n        \"items\": [\n            {\n                \"id\": \"1\",\n                \"name\": \"original t-shirt\",\n                \"unitprice\": \"240.00\"\n            },\n            {\n                \"id\": \"2\",\n                \"name\": \"Cotton Polo Shirt\",\n                \"unitprice\": \"123.00\"\n            }\n        ]\n    }\n]\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F91ahmed%2Fjsonmodifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F91ahmed%2Fjsonmodifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F91ahmed%2Fjsonmodifier/lists"}