定制 ridvanaltun/json-patch-generator 二次开发

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

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

ridvanaltun/json-patch-generator

最新稳定版本:v1.1.0

Composer 安装命令:

composer require ridvanaltun/json-patch-generator

包简介

Create JSON Patch (IETF RFC-6902).

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License composer.lock

Generate JSON Patch (IETF RFC-6902).

This library allows you generate json-patch in PHP.

Installation

$ composer require ridvanaltun/json-patch-generator

Usage

<?php require_once __DIR__ . '/vendor/autoload.php'; use ridvanaltun\JsonPatchGenerator\Utils; $utils = new Utils(); $oldSnap = [ 'name' => 'foo', 'surname' => 'bar', 'skils' => [ 'computer_science' => true, 'algorithm' => true, 'math' => false, ], 'specs' => [ 'a', 'b', 'c', ] ]; $currSnap = [ 'name' => 'foo', 'age' => 23, 'skils' => [ 'computer_science' => true, 'algorithm' => false, ], 'specs' => [ 'a', 'b', 'd', 'e', ] ]; $jsonPatch = $utils->generateJsonPatch($currSnap, $oldSnap); var_dump($jsonPatch);

OUTPUT:

array(7) { [0]=> array(3) { ["op"]=> string(3) "add" ["path"]=> string(4) "/age" ["value"]=> int(23) } [1]=> array(3) { ["op"]=> string(7) "replace" ["path"]=> string(16) "/skils/algorithm" ["value"]=> bool(false) } [2]=> array(3) { ["op"]=> string(3) "add" ["path"]=> string(6) "/specs" ["value"]=> string(1) "d" } [3]=> array(3) { ["op"]=> string(3) "add" ["path"]=> string(6) "/specs" ["value"]=> string(1) "e" } [4]=> array(2) { ["op"]=> string(6) "remove" ["path"]=> string(8) "/surname" } [5]=> array(2) { ["op"]=> string(6) "remove" ["path"]=> string(11) "/skils/math" } [6]=> array(3) { ["op"]=> string(6) "remove" ["path"]=> string(6) "/specs" ["value"]=> string(1) "c" } } 

统计信息

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

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固