aeson-diff: Extract and apply patches to JSON documents.

[ algorithms, bsd3, json, library, program, web ] [ Propose Tags ]

This is a small library for working with changes to JSON documents. It includes a library and two command-line executables in the style of the diff(1) and patch(1) commands available on many systems.


[Skip to Readme]

Modules

[Index]

Downloads

Note: This package has metadata revisions in the cabal description newer than included in the tarball. To unpack the package including the revisions, use 'cabal get'.

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

Versions [RSS] 0.1.1.1, 0.1.1.2, 0.1.1.3, 1.0.0.0, 1.0.0.1, 1.1.0.0, 1.1.0.2, 1.1.0.3, 1.1.0.4, 1.1.0.5, 1.1.0.7, 1.1.0.8, 1.1.0.9, 1.1.0.10, 1.1.0.11, 1.1.0.12, 1.1.0.13
Change log CHANGELOG.md
Dependencies aeson (<1.2.2), aeson-diff, base (>=4.5 && <4.9), bytestring (>=0.10), edit-distance-vector, hashable, mtl, optparse-applicative (>=0.11 && <0.13), scientific, text, unordered-containers, vector [details]
License BSD-3-Clause
Copyright (c) 2015 Thomas Sutton and others.
Author Thomas Sutton
Maintainer me@thomas-sutton.id.au
Revised Revision 2 made by janus at 2022-02-24T20:54:29Z
Category JSON, Web, Algorithms
Home page https://github.com/thsutton/aeson-diff
Source repo head: git clone https://github.com/thsutton/aeson-diff
Uploaded by ThomasSutton at 2016-01-11T22:22:50Z
Distributions Arch:1.1.0.13, Debian:1.1.0.9, LTSHaskell:1.1.0.13, NixOS:1.1.0.13, Stackage:1.1.0.13
Reverse Dependencies 5 direct, 3 indirect [details]
Executables json-patch, json-diff
Downloads 12911 total (59 in the last 30 days)
Rating 2.0 (votes: 1) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2016-01-11 [all 1 reports]

Readme for aeson-diff-0.1.1.3

[back to package description]

Aeson Diff

Build Status

This is a small library for working with changes to JSON documents. It includes a library and two executables in the style of diff(1) and patch(1).

Installing

The aeson-diff package is written in Haskell and can be installed using the Cabal package management tool.

For the command-line tools only, I recommend using Cabal's sandbox functionality to avoid installing the associated libraries globally on your system. This approach might look something like the following:

cd aeson-diff/
cabal sandbox init
cabal install --dependencies-only
cabal build
sudo mkdir -p /usr/local/bin
sudo cp dist/build/json-*/json-{diff,patch} /usr/local/bin/

If you want to use the library, use Cabal in a sandbox or not according to your preference.

cabal sandbox init
cabal sandbox install ~/Downloads/aeson-diff/

Usage

json-diff command

The json-diff command compares two JSON documents and extracts a patch describing the differences between the first document and the second.

Usage: json-diff [-j|--json] [-o|--output OUTPUT] FROM TO
Generate a patch between two JSON documents.

Available options:
    -h,--help                Show this help text
    -j,--json                Output patch in JSON.

json-patch command

The json-patch command applies a patch describing changes to be made to a JSON document.

Usage: json-patch [-j|--json] [-o|--output OUTPUT] PATCH FROM
Generate a patch between two JSON documents.

Available options:
  -h,--help                Show this help text
  -j,--json                Patch is in JSON format.
  -o,--output OUTPUT       Destination for patched JSON.
  PATCH                    Patch to apply.
  FROM                     JSON file to patch.

aeson-diff library

The aeson-diff library exports as single module: Data.Aeson.Diff. This exports diff and patch functions which do exactly what might be expected:

  • diff :: Value -> Value -> Patch examines source and target JSON Values and constructs a new Patch describing the changes.

  • patch :: Patch -> Value -> Value applies the changes in a Patch to a JSON Value.

For more complete information, see the documentation.