承接 konsulting/json-diff 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

konsulting/json-diff

最新稳定版本:1.0.2

Composer 安装命令:

composer require konsulting/json-diff

包简介

无描述信息

README 文档

README

Get a readable diff from two bits of JSON.

Installation

composer require konsulting/json-diff

Usage

There are a few ways to use the class. It depends on your preference, see the example below. It is also possible to exclude a set of keys from the diff, also shown below.

<?php use Konsulting\JsonDiff; // Using 'new' $diff = (new JsonDiff('["json"]'))->exclude(['key'])->compareTo('["different_json"]'); // Using a simple factory method $diff = JsonDiff::original('["json"]')->exclude(['key'])->compareTo('["different_json"]'); // Using a simple 'all-in-one' static method. $diff = JsonDiff::compare($original = '["json"]', $new = '["different_json"]', $exclude = ['key']);

The output is a JsonDiffResult that stores the following information:

  • original - the original json as an array
  • new - the new json as an array
  • added - what was added
  • removed - what was removed
  • diff - a combined diff of added and removed as an array
  • changed - a boolean signifying if there was a relevant change

The JsonDiffResult allows access of the result in several ways:

<?php $diff->toArray(); [ 'original' => ['...'], 'new' => ['...'], 'diff' => [ 'added' => ['...'], 'removed' => ['...'] ], 'changed' => true // or false if nothing changed ]; $diff->toJson(); // Json representation of toArray() // All the properties can be accessed using array or object notation; // original, new, added, removed, diff, changed. $diff->diff; $diff['diff'];

Contributing

Contributions are welcome and will be fully credited. We will accept contributions by Pull Request.

Please:

  • Use the PSR-2 Coding Standard
  • Add tests, if you’re not sure how, please ask.
  • Document changes in behaviour, including readme.md.

Testing

We use PHPUnit

Run tests using PHPUnit: vendor/bin/phpunit

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固