Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fast-json-patch

Package Overview
Dependencies
Maintainers
2
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-json-patch

Fast implementation of JSON-Patch (RFC-6902) with duplex (observe changes) capabilities

  • 1.1.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3M
decreased by-4.3%
Maintainers
2
Weekly downloads
 
Created

What is fast-json-patch?

The fast-json-patch package allows for the observation of changes to a JSON document, generating JSON Patch documents to capture these changes, and applying such patches to JSON documents. It is useful for efficiently synchronizing JSON data between clients and servers or among components of an application.

What are fast-json-patch's main functionalities?

Generating patches

This feature allows for the observation of a JSON document and the generation of a JSON Patch document representing the changes made to the observed document.

const jsonpatch = require('fast-json-patch');
const document = { firstName: 'Albert', contact: { phone: '123' } };
const observer = jsonpatch.observe(document);
document.firstName = 'Joachim';
document.contact.phone = '456';
const patches = jsonpatch.generate(observer);

Applying patches

This feature applies a JSON Patch document to a JSON document, modifying the target document according to the operations described in the patch.

const jsonpatch = require('fast-json-patch');
const document = { firstName: 'Albert', contact: { phone: '123' } };
const patches = [{ op: 'replace', path: '/firstName', value: 'Joachim' }, { op: 'replace', path: '/contact/phone', value: '456' }];
jsonpatch.applyPatch(document, patches);

Validating a sequence of operations

This feature validates a sequence of operations against a JSON document to ensure they can be applied without errors, providing a way to check patches for correctness before application.

const jsonpatch = require('fast-json-patch');
const document = { firstName: 'Albert', contact: { phone: '123' } };
const patches = [{ op: 'replace', path: '/firstName', value: 'Joachim' }, { op: 'add', path: '/lastName', value: 'Wagner' }];
const validationResult = jsonpatch.validate(patches, document);

Other packages similar to fast-json-patch

Keywords

FAQs

Package last updated on 17 Feb 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc