{"id":15698215,"url":"https://github.com/dcblogdev/php-find-and-replace-json","last_synced_at":"2025-05-08T22:31:21.170Z","repository":{"id":41397763,"uuid":"245631268","full_name":"dcblogdev/php-find-and-replace-json","owner":"dcblogdev","description":null,"archived":false,"fork":false,"pushed_at":"2022-07-20T22:35:12.000Z","size":16,"stargazers_count":6,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-14T20:17:15.695Z","etag":null,"topics":["hacktoberfest"],"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/dcblogdev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":["dcblogdev"]}},"created_at":"2020-03-07T12:45:21.000Z","updated_at":"2022-12-27T00:43:20.000Z","dependencies_parsed_at":"2022-08-10T02:07:18.240Z","dependency_job_id":null,"html_url":"https://github.com/dcblogdev/php-find-and-replace-json","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/dcblogdev%2Fphp-find-and-replace-json","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcblogdev%2Fphp-find-and-replace-json/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcblogdev%2Fphp-find-and-replace-json/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dcblogdev%2Fphp-find-and-replace-json/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dcblogdev","download_url":"https://codeload.github.com/dcblogdev/php-find-and-replace-json/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253157720,"owners_count":21863157,"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":["hacktoberfest"],"created_at":"2024-10-03T19:23:56.592Z","updated_at":"2025-05-08T22:31:21.151Z","avatar_url":"https://github.com/dcblogdev.png","language":"PHP","readme":"[![Latest Version on Packagist](https://img.shields.io/packagist/v/dcblogdev/php-find-and-replace-json.svg?style=flat-square)](https://packagist.org/packages/dcblogdev/php-find-and-replace-json)\n[![Total Downloads](https://img.shields.io/packagist/dt/dcblogdev/php-find-and-replace-json.svg?style=flat-square)](https://packagist.org/packages/dcblogdev/php-find-and-replace-json)\n\n![Logo](https://repository-images.githubusercontent.com/245631268/aa9e9480-49c0-11eb-91c4-1bd9c9660361)\n\nTakes a JSON payload and replaces either a key or value from a provided array.\n\n## Install\n\nInstall via Composer\n\n```console\ncomposer require dcblogdev/php-find-and-replace-json\n```\n\n## Usage\n\nProvide a JSON array and an array containing values to replace.\n\nCreate an instance of FindAndReplaceJson call replace and pass in the JSON array and array of replacing values.\n\nJSON is returned with the replaced values. Keys can also be replaced by specifying named keys in $replaces array.\n\n```php\n$payload = json_encode([\n    'name'   =\u003e 'Joe Bloggs',\n    'age'   =\u003e 23,\n    'location' =\u003e 'London',\n]);\n\n//let's replace the values for age and location\n$replaces = [\n    'age' =\u003e 45, \n    'location' =\u003e \"Manchester\"\n];\n\n$runner = new FindAndReplaceJson();\nreturn $runner-\u003ereplace($payload, $replaces);\n```\n\nResult:\n\n```json\n{\n  \"name\": \"Joe Bloggs\",\n  \"age\": \"45\",\n  \"location\": \"Manchester\"\n}\n```\n\nBy default, JSON is expected but a normal array can be used by passing false as the third argument to FindAndReplaceJson.\nWhen the third argument (`$isJson`) is set to false FindAndReplaceJson expects an array and will return an array.\n\n## Contributing\n\nContributions are welcome and will be fully credited.\n\nContributions are accepted via Pull Requests on [Github][4].\n\n## Pull Requests\n\n- **Document any change in behaviour** - Make sure the `readme.md` and any other relevant documentation are kept up-to-date.\n\n- **Consider our release cycle** - We try to follow [SemVer v2.0.0][5]. Randomly breaking public APIs is not an option.\n\n- **One pull request per feature** - If you want to do more than one thing, send multiple pull requests.\n\n## Running Tests\n\nTo run unit tests, simply execute the following command in your console:\n\n```console\nvendor/bin/phpunit\n```\n\n\n## Security\n\nIf you discover any security related issues, please email dave@dcblog.dev email instead of using the issue tracker.\n\n## License\n\nPlease see the [license file][6] for more information.\n\n[4]:    https://github.com/dcblogdev/find-and-replace-json\n[5]:    http://semver.org/\n[6]:    license.md\n","funding_links":["https://github.com/sponsors/dcblogdev"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcblogdev%2Fphp-find-and-replace-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdcblogdev%2Fphp-find-and-replace-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdcblogdev%2Fphp-find-and-replace-json/lists"}