stolt/json-merge-patch
Composer 安装命令:
composer require stolt/json-merge-patch
包简介
Implementation of JSON Merge Patch (https://tools.ietf.org/html/rfc7396).
README 文档
README
This is an(other) implementation of JSON Merge Patch written in PHP. For a PHP 5.3 compatible version please use the implementation by @clue.
Installation via Composer
composer require stolt/json-merge-patch
Usage
Now you can use JSON Merge Patch for PHP via the available Composer autoload file.
Apply a patch
<?php require_once 'vendor/autoload.php'; use Rs\Json\Merge\Patch; $targetDocument = json_decode('{"title":"Goodbye!","author":{"givenName":"John","familyName":"Doe"},"tags":["example","sample"],"content":"This will be unchanged"}'); $patchDocument = json_decode('{"title":"Hello!","phoneNumber":"+01-123-456-7890","author":{"familyName":null},"tags":["example"]}'); $patchedDocument = (new Patch())->apply( $targetDocument, $patchDocument ); // '{"title":"Hello!","author":{"givenName":"John"},"tags":["example"],"content":"This will be unchanged","phoneNumber":"+01-123-456-7890"}'
Generate a patch document
<?php require_once 'vendor/autoload.php'; use Rs\Json\Merge\Patch; $sourceDocument = json_decode('{"a":"b","b":"c"}'); $targetDocument = json_decode('{"b":"c"}'); $generatedPatchDocument = (new Patch())->generate( $sourceDocument, $targetDocument ); // '{"a":null}'
Merge patch documents
<?php require_once 'vendor/autoload.php'; use Rs\Json\Merge\Patch; $patchDocument1 = json_decode('{"a":"b"}'); $patchDocument2 = json_decode('{"b":"c"}'); $mergedPatchDocument = (new Patch())->merge( $patchDocument1, $patchDocument2 ); // '{"a":"b","b":"c"}'
Running tests
composer test
License
This library is licensed under the MIT license. Please see LICENSE for more details.
Changelog
Please see CHANGELOG for more details.
Contributing
Please see CONTRIBUTING for more details.
stolt/json-merge-patch 适用场景与选型建议
stolt/json-merge-patch 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 250.45k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2015 年 06 月 09 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「json」 「json modification」 「JSON merge patch」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 stolt/json-merge-patch 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 stolt/json-merge-patch 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 stolt/json-merge-patch 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Implementation of JSON Patch (http://tools.ietf.org/html/rfc6902)
PHP PDF Merger
Kinikit - PHP Application development framework MVC component
Symfony 7/8 DmytrofDoctrineModificationEventsBundle to create and handle events on entities updates
Forked from https://github.com/deltaaskii/lara-pdf-merger. Add condition if(!class_exists('TCPDF')) (depreciated in php 7.2) to foreach.
Assetic cache busting worker. Adds a hash to the filename based on file content.
统计信息
- 总下载量: 250.45k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 28
- 依赖项目数: 4
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-06-09