定制 dcblogdev/php-find-and-replace-json 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

dcblogdev/php-find-and-replace-json

最新稳定版本:v1.1.2

Composer 安装命令:

composer require dcblogdev/php-find-and-replace-json

包简介

Find and replace keys or values in json or arrays

README 文档

README

Latest Version on Packagist Total Downloads

Logo

Takes a JSON payload and replaces either a key or value from a provided array.

Install

Install via Composer

composer require dcblogdev/php-find-and-replace-json

Usage

Provide a JSON array and an array containing values to replace.

Create an instance of FindAndReplaceJson call replace and pass in the JSON array and array of replacing values.

JSON is returned with the replaced values. Keys can also be replaced by specifying named keys in $replaces array.

$payload = json_encode([
    'name'   => 'Joe Bloggs',
    'age'   => 23,
    'location' => 'London',
]);

//let's replace the values for age and location
$replaces = [
    'age' => 45, 
    'location' => "Manchester"
];

$runner = new FindAndReplaceJson();
return $runner->replace($payload, $replaces);

Result:

{
  "name": "Joe Bloggs",
  "age": "45",
  "location": "Manchester"
}

By default, JSON is expected but a normal array can be used by passing false as the third argument to FindAndReplaceJson. When the third argument ($isJson) is set to false FindAndReplaceJson expects an array and will return an array.

Contributing

Contributions are welcome and will be fully credited.

Contributions are accepted via Pull Requests on Github.

Pull Requests

  • Document any change in behaviour - Make sure the readme.md and any other relevant documentation are kept up-to-date.

  • Consider our release cycle - We try to follow SemVer v2.0.0. Randomly breaking public APIs is not an option.

  • One pull request per feature - If you want to do more than one thing, send multiple pull requests.

Running Tests

To run unit tests, simply execute the following command in your console:

vendor/bin/phpunit

Security

If you discover any security related issues, please email dave@dcblog.dev email instead of using the issue tracker.

License

Please see the license file for more information.

统计信息

  • 总下载量: 1.12k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 2
  • Forks: 2
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固