PHPackages                             victuxbb/jsonpatch - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. victuxbb/jsonpatch

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

victuxbb/jsonpatch
==================

Implementation of JSON Patch (http://tools.ietf.org/html/rfc6902)

v1.0.1(11y ago)521.7k1MITPHPPHP &gt;=5.3.3

Since Dec 18Pushed 11y ago4 watchersCompare

[ Source](https://github.com/victuxbb/jsonpatch)[ Packagist](https://packagist.org/packages/victuxbb/jsonpatch)[ Docs](https://github.com/victuxbb/jsonpatch)[ RSS](/packages/victuxbb-jsonpatch/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (1)Versions (4)Used By (0)

jsonpatch
=========

[](#jsonpatch)

[![SensioLabsInsight](https://camo.githubusercontent.com/be0cb60020dd93a4b666bd2e00b4043818bb529b5f3e9d7c6921602e3fc629b3/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f64656539353633372d303134312d346361612d623662662d3131383961383438313238632f6269672e706e67)](https://insight.sensiolabs.com/projects/dee95637-0141-4caa-b6bf-1189a848128c)

Implementation of JSON Patch () in PHP

Installation
------------

[](#installation)

Require [`victuxbb/jsonpatch`](https://packagist.org/packages/victuxbb/jsonpatch)into your `composer.json` file:

```
{
    "require": {
        "victuxbb/jsonpatch": "@stable"
    }
}
```

or inside your root project directory

```
$ composer require victuxbb/jsonpatch @stable
```

Documentation
-------------

[](#documentation)

With a target JSON like this:

```
$targetJSON ='{"baz": "qux","foo": "bar"}';
```

and a variable with a JSON string operations:

```
$patchOperations = '[
     { "op": "replace", "path": "/baz", "value": "boo" }
   ]';
```

create a instance of Patcher and use the "patch" method to get the json result:

```
$patcher = new Patcher();
$result = $patcher->patch($targetJSON,$patchOperations);
```

$result will contain:

```
{"baz":"boo","foo":"bar"}
```

A typical use case with FOSRestBundle and JMSSerializer:

```
public function patchUserAction(Request $request,User $user)
    {
        $json = $request->getContent();
        $jps = $this->get('json_patch_service'); //symfony service that loads Patcher.php
        $serializer = $this->get("jms_serializer");

        $serializerGroup = array('view');

        $sc = SerializationContext::create();
        $sc->setGroups($serializerGroup);

        $jsonUser = $serializer->serialize($user,'json',$sc); //Generating the json target of object that we want to update
        $jsonUser = $jps->patch($jsonUser,$json); //json result with the changes applied of the json operations

        $dc = DeserializationContext::create();
        $dc->setAttribute('target',$user);

        //Restore the doctrine entity object with deserialization and targeting the object with DeserializationContext
        $serializer->deserialize($jsonUser,'Groupalia\BizApiBundle\Entity\User','json',$dc);

        $em = $this->getDoctrine()->getManager();
        $em->persist($user);
        $em->flush();

        $response = new Response();
        $response->setStatusCode(200);

        return $response;

    }
```

Thanks to
---------

[](#thanks-to)

\*

\*

\*

\*

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~24 days

Total

2

Last Release

4145d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/92e590eabd3fd7786f4160d86d4bb7057c1c47e945ef4419ab4538c2dd6224e6?d=identicon)[victuxbb](/maintainers/victuxbb)

---

Top Contributors

[![victuxbb](https://avatars.githubusercontent.com/u/9658700?v=4)](https://github.com/victuxbb "victuxbb (12 commits)")

---

Tags

jsonjson pointerjson operationspatch operations

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/victuxbb-jsonpatch/health.svg)

```
[![Health](https://phpackages.com/badges/victuxbb-jsonpatch/health.svg)](https://phpackages.com/packages/victuxbb-jsonpatch)
```

###  Alternatives

[justinrainbow/json-schema

A library to validate a json schema.

3.6k316.9M612](/packages/justinrainbow-json-schema)[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[jms/serializer

Library for (de-)serializing data of any complexity; supports XML, and JSON.

2.3k135.8M851](/packages/jms-serializer)[jms/serializer-bundle

Allows you to easily serialize, and deserialize data of any complexity

1.8k89.3M627](/packages/jms-serializer-bundle)[php-jsonpointer/php-jsonpointer

Implementation of JSON Pointer (http://tools.ietf.org/html/rfc6901)

8915.1M11](/packages/php-jsonpointer-php-jsonpointer)[colinodell/json5

UTF-8 compatible JSON5 parser for PHP

30422.2M45](/packages/colinodell-json5)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
