aeson-diff-1.1.0.13: Extract and apply patches to JSON documents.
Safe HaskellNone
LanguageHaskell2010

Data.Aeson.Diff

Description

This module implements data types and operations to represent the differences between JSON documents (i.e. a patch), to compare JSON documents and extract such a patch, and to apply such a patch to a JSON document.

Synopsis

Patches

newtype Patch Source #

Describes the changes between two JSON documents.

Constructors

Patch [Operation] 

Instances

Instances details
Eq Patch Source # 
Instance details

Defined in Data.Aeson.Patch

Methods

(==) :: Patch -> Patch -> Bool #

(/=) :: Patch -> Patch -> Bool #

Show Patch Source # 
Instance details

Defined in Data.Aeson.Patch

Methods

showsPrec :: Int -> Patch -> ShowS #

show :: Patch -> String #

showList :: [Patch] -> ShowS #

Generic Patch Source # 
Instance details

Defined in Data.Aeson.Patch

Associated Types

type Rep Patch :: Type -> Type #

Methods

from :: Patch -> Rep Patch x #

to :: Rep Patch x -> Patch #

Semigroup Patch Source # 
Instance details

Defined in Data.Aeson.Patch

Methods

(<>) :: Patch -> Patch -> Patch #

sconcat :: NonEmpty Patch -> Patch #

stimes :: Integral b => b -> Patch -> Patch #

Monoid Patch Source # 
Instance details

Defined in Data.Aeson.Patch

Methods

mempty :: Patch #

mappend :: Patch -> Patch -> Patch #

mconcat :: [Patch] -> Patch #

ToJSON Patch Source # 
Instance details

Defined in Data.Aeson.Patch

FromJSON Patch Source # 
Instance details

Defined in Data.Aeson.Patch

type Rep Patch Source # 
Instance details

Defined in Data.Aeson.Patch

type Rep Patch = D1 ('MetaData "Patch" "Data.Aeson.Patch" "aeson-diff-1.1.0.13-6QblOqYnPOz5hBmSgcA7GZ" 'True) (C1 ('MetaCons "Patch" 'PrefixI 'True) (S1 ('MetaSel ('Just "patchOperations") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Operation])))

data Pointer Source #

Pointer to a location in a JSON document.

Defined in RFC 6901 http://tools.ietf.org/html/rfc6901

Instances

Instances details
Eq Pointer Source # 
Instance details

Defined in Data.Aeson.Pointer

Methods

(==) :: Pointer -> Pointer -> Bool #

(/=) :: Pointer -> Pointer -> Bool #

Ord Pointer Source # 
Instance details

Defined in Data.Aeson.Pointer

Show Pointer Source # 
Instance details

Defined in Data.Aeson.Pointer

Generic Pointer Source # 
Instance details

Defined in Data.Aeson.Pointer

Associated Types

type Rep Pointer :: Type -> Type #

Methods

from :: Pointer -> Rep Pointer x #

to :: Rep Pointer x -> Pointer #

Semigroup Pointer Source # 
Instance details

Defined in Data.Aeson.Pointer

Monoid Pointer Source # 
Instance details

Defined in Data.Aeson.Pointer

ToJSON Pointer Source # 
Instance details

Defined in Data.Aeson.Pointer

FromJSON Pointer Source # 
Instance details

Defined in Data.Aeson.Pointer

type Rep Pointer Source # 
Instance details

Defined in Data.Aeson.Pointer

type Rep Pointer = D1 ('MetaData "Pointer" "Data.Aeson.Pointer" "aeson-diff-1.1.0.13-6QblOqYnPOz5hBmSgcA7GZ" 'True) (C1 ('MetaCons "Pointer" 'PrefixI 'True) (S1 ('MetaSel ('Just "pointerPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Path)))

data Key Source #

Path components to traverse a single layer of a JSON document.

Constructors

OKey Key

Traverse a Value with an Object constructor.

AKey Int

Traverse a Value with an Array constructor.

Instances

Instances details
Eq Key Source # 
Instance details

Defined in Data.Aeson.Pointer

Methods

(==) :: Key -> Key -> Bool #

(/=) :: Key -> Key -> Bool #

Ord Key Source # 
Instance details

Defined in Data.Aeson.Pointer

Methods

compare :: Key -> Key -> Ordering #

(<) :: Key -> Key -> Bool #

(<=) :: Key -> Key -> Bool #

(>) :: Key -> Key -> Bool #

(>=) :: Key -> Key -> Bool #

max :: Key -> Key -> Key #

min :: Key -> Key -> Key #

Show Key Source # 
Instance details

Defined in Data.Aeson.Pointer

Methods

showsPrec :: Int -> Key -> ShowS #

show :: Key -> String #

showList :: [Key] -> ShowS #

Generic Key Source # 
Instance details

Defined in Data.Aeson.Pointer

Associated Types

type Rep Key :: Type -> Type #

Methods

from :: Key -> Rep Key x #

to :: Rep Key x -> Key #

ToJSON Key Source # 
Instance details

Defined in Data.Aeson.Pointer

FromJSON Key Source # 
Instance details

Defined in Data.Aeson.Pointer

type Rep Key Source # 
Instance details

Defined in Data.Aeson.Pointer

type Rep Key = D1 ('MetaData "Key" "Data.Aeson.Pointer" "aeson-diff-1.1.0.13-6QblOqYnPOz5hBmSgcA7GZ" 'False) (C1 ('MetaCons "OKey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Key)) :+: C1 ('MetaCons "AKey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

data Operation Source #

An Operation describes the operations which can appear as part of a JSON Patch.

See RFC 6902 Section 4 http://tools.ietf.org/html/rfc6902#section-4.

Instances

Instances details
Eq Operation Source # 
Instance details

Defined in Data.Aeson.Patch

Show Operation Source # 
Instance details

Defined in Data.Aeson.Patch

Generic Operation Source # 
Instance details

Defined in Data.Aeson.Patch

Associated Types

type Rep Operation :: Type -> Type #

ToJSON Operation Source # 
Instance details

Defined in Data.Aeson.Patch

FromJSON Operation Source # 
Instance details

Defined in Data.Aeson.Patch

type Rep Operation Source # 
Instance details

Defined in Data.Aeson.Patch

type Rep Operation = D1 ('MetaData "Operation" "Data.Aeson.Patch" "aeson-diff-1.1.0.13-6QblOqYnPOz5hBmSgcA7GZ" 'False) ((C1 ('MetaCons "Add" 'PrefixI 'True) (S1 ('MetaSel ('Just "changePointer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pointer) :*: S1 ('MetaSel ('Just "changeValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value)) :+: (C1 ('MetaCons "Cpy" 'PrefixI 'True) (S1 ('MetaSel ('Just "changePointer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pointer) :*: S1 ('MetaSel ('Just "fromPointer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pointer)) :+: C1 ('MetaCons "Mov" 'PrefixI 'True) (S1 ('MetaSel ('Just "changePointer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pointer) :*: S1 ('MetaSel ('Just "fromPointer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pointer)))) :+: (C1 ('MetaCons "Rem" 'PrefixI 'True) (S1 ('MetaSel ('Just "changePointer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pointer)) :+: (C1 ('MetaCons "Rep" 'PrefixI 'True) (S1 ('MetaSel ('Just "changePointer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pointer) :*: S1 ('MetaSel ('Just "changeValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value)) :+: C1 ('MetaCons "Tst" 'PrefixI 'True) (S1 ('MetaSel ('Just "changePointer") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Pointer) :*: S1 ('MetaSel ('Just "changeValue") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Value)))))

newtype Config Source #

Configuration for the diff algorithm.

Constructors

Config 

Functions

diff :: Value -> Value -> Patch Source #

Compare two JSON documents and generate a patch describing the differences.

Uses the defaultConfig.

diff' :: Config -> Value -> Value -> Patch Source #

Compare two JSON documents and generate a patch describing the differences.

patch :: Patch -> Value -> Result Value Source #

Apply a patch to a JSON document.