承接 remorhaz/php-json-patch 相关项目开发

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

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

remorhaz/php-json-patch

最新稳定版本:v0.6.1

Composer 安装命令:

composer require remorhaz/php-json-patch

包简介

JSON Patch (RFC-6902) PHP implementation

README 文档

README

Latest Stable Version Build Scrutinizer Code Quality codecov Mutation testing badgeTotal Downloads License

This library implements RFC6902-compliant JSON patch tool.

Requirements

Installation

You will need composer to perform install.

composer require remorhaz/php-json-patch 

Documentation

Accessing JSON document

You can create accessible JSON document either from encoded JSON string or from decoded JSON data using corresponding node value factory:

use Remorhaz\JSON\Data\Value\EncodedJson; use Remorhaz\JSON\Data\Value\DecodedJson; // Creating document from JSON-encoded string: $encodedValueFactory = EncodedJson\NodeValueFactory::create(); $encodedJson = '{"a":1}'; $document1 = $encodedValueFactory->createValue($encodedJson); // Creating document from decoded JSON data: $decodedValueFactory = DecodedJson\NodeValueFactory::create(); $decodedJson = (object) ['a' => 1]; $document2 = $decodedValueFactory->createValue($decodedJson);

Creating and processing query

You should use query factory to create query from JSON Patch document. Then you should use processor to apply that query:

<?php use Remorhaz\JSON\Data\Value\EncodedJson; use Remorhaz\JSON\Patch\Processor\Processor; use Remorhaz\JSON\Patch\Query\QueryFactory; $encodedValueFactory = EncodedJson\NodeValueFactory::create(); $queryFactory = QueryFactory::create(); $processor = Processor::create(); $patch = $encodedValueFactory->createValue('[{"op":"remove","path":"/0"}]'); $query = $queryFactory->createQuery($patch); $document = $encodedValueFactory->createValue('[1,2]'); $result = $processor->apply($query, $document); var_dump($result->encode()); // string: '[2]' var_dump($result->decode()); // array: [2]

Note that result can be exported either to JSON-encoded string or to raw PHP value.

License

PHP JSON Patch is licensed under MIT license.

统计信息

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

GitHub 信息

  • Stars: 5
  • Watchers: 2
  • Forks: 1
  • 开发语言: PHP

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固