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

Safe Haskell | None
Language | Haskell2010

Data.Aeson.Patch

Contents

- Modification
- Predicates

Description

Synopsis

- newtype Patch = Patch {
  - patchOperations :: [Operation]
  }
- data Operation
  - = Add {
    - changePointer :: Pointer
    - changeValue :: Value
    }
  - | Cpy {
    - changePointer :: Pointer
    - fromPointer :: Pointer
    }
  - | Mov {
    - changePointer :: Pointer
    - fromPointer :: Pointer
    }
  - | Rem {
    - changePointer :: Pointer
    }
  - | Rep {
    - changePointer :: Pointer
    - changeValue :: Value
    }
  - | Tst {
    - changePointer :: Pointer
    - changeValue :: Value
    }
- modifyPointer :: (Pointer -> Pointer) -> Operation -> Operation
- modifyPointers :: (Pointer -> Pointer) -> Patch -> Patch
- isAdd :: Operation -> Bool
- isRem :: Operation -> Bool
- isRep :: Operation -> Bool
- isMov :: Operation -> Bool
- isCpy :: Operation -> Bool
- isTst :: Operation -> Bool

# Documentation

newtype Patch Source #

Describes the changes between two JSON documents.

Constructors

Patch |

Fields

- patchOperations :: [Operation]

#### Instances

Instances details

FromJSON Patch Source # |
Instance details Defined in Data.Aeson.Patch Methods parseJSON :: Value -> Parser Patch Source # parseJSONList :: Value -> Parser [Patch] Source # omittedField :: Maybe Patch Source #
ToJSON Patch Source # |
Instance details Defined in Data.Aeson.Patch Methods toJSON :: Patch -> Value Source # toEncoding :: Patch -> Encoding Source # toJSONList :: [Patch] -> Value Source # toEncodingList :: [Patch] -> Encoding Source # omitField :: Patch -> Bool Source #
Monoid Patch Source # |
Instance details Defined in Data.Aeson.Patch Methods mempty :: Patch Source # mappend :: Patch -> Patch -> Patch Source # mconcat :: [Patch] -> Patch Source #
Semigroup Patch Source # |
Instance details Defined in Data.Aeson.Patch Methods (<>) :: Patch -> Patch -> Patch Source # sconcat :: NonEmpty Patch -> Patch Source # stimes :: Integral b => b -> Patch -> Patch Source #
Generic Patch Source # |

Instance details

Defined in Data.Aeson.Patch

Associated Types

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

Methods

from :: Patch -> Rep Patch x Source #

to :: Rep Patch x -> Patch Source #

Show Patch Source # |
Instance details Defined in Data.Aeson.Patch Methods showsPrec :: Int -> Patch -> ShowS Source # show :: Patch -> String Source # showList :: [Patch] -> ShowS Source #
Eq Patch Source # |
Instance details Defined in Data.Aeson.Patch Methods (==) :: Patch -> Patch -> Bool Source # (/=) :: Patch -> Patch -> Bool Source #
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-RSEUjrZ5DXI4WojbDRtMt" 'True) (C1 ('MetaCons "Patch" 'PrefixI 'True) (S1 ('MetaSel ('Just "patchOperations") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 [Operation])))

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.

Constructors

Add | http://tools.ietf.org/html/rfc6902#section-4.1

Fields

- changePointer :: Pointer
- changeValue :: Value

Cpy | http://tools.ietf.org/html/rfc6902#section-4.5

Fields

- changePointer :: Pointer
- fromPointer :: Pointer

Mov | http://tools.ietf.org/html/rfc6902#section-4.4

Fields

- changePointer :: Pointer
- fromPointer :: Pointer

Rem | http://tools.ietf.org/html/rfc6902#section-4.2

Fields

- changePointer :: Pointer

Rep | http://tools.ietf.org/html/rfc6902#section-4.3

Fields

- changePointer :: Pointer
- changeValue :: Value

Tst | http://tools.ietf.org/html/rfc6902#section-4.6

Fields

- changePointer :: Pointer
- changeValue :: Value

#### Instances

Instances details

FromJSON Operation Source # |
Instance details Defined in Data.Aeson.Patch Methods parseJSON :: Value -> Parser Operation Source # parseJSONList :: Value -> Parser [Operation] Source # omittedField :: Maybe Operation Source #
ToJSON Operation Source # |
Instance details Defined in Data.Aeson.Patch Methods toJSON :: Operation -> Value Source # toEncoding :: Operation -> Encoding Source # toJSONList :: [Operation] -> Value Source # toEncodingList :: [Operation] -> Encoding Source # omitField :: Operation -> Bool Source #
Generic Operation Source # |

Instance details

Defined in Data.Aeson.Patch

Associated Types

type Rep Operation |

Instance details

Defined in Data.Aeson.Patch

type Rep Operation = D1 ('MetaData "Operation" "Data.Aeson.Patch" "aeson-diff-1.1.0.13-RSEUjrZ5DXI4WojbDRtMt" '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)))))

Methods

from :: Operation -> Rep Operation x Source #

to :: Rep Operation x -> Operation Source #

Show Operation Source # |
Instance details Defined in Data.Aeson.Patch Methods showsPrec :: Int -> Operation -> ShowS Source # show :: Operation -> String Source # showList :: [Operation] -> ShowS Source #
Eq Operation Source # |
Instance details Defined in Data.Aeson.Patch Methods (==) :: Operation -> Operation -> Bool Source # (/=) :: Operation -> Operation -> Bool Source #
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-RSEUjrZ5DXI4WojbDRtMt" '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)))))

# Modification

modifyPointer :: (Pointer -> Pointer) -> Operation -> Operation Source #

Modify the `Pointer`s in an `Operation`.

If the operation contains multiple pointers (i.e. a `Mov` or `Cpy`) then both will be modified.

modifyPointers :: (Pointer -> Pointer) -> Patch -> Patch Source #

Modify the pointers in the `Operation`s of a `Patch`.

See `modifyPointer` for details.

# Predicates

isAdd :: Operation -> Bool Source #

isRem :: Operation -> Bool Source #

isRep :: Operation -> Bool Source #

isMov :: Operation -> Bool Source #

isCpy :: Operation -> Bool Source #

isTst :: Operation -> Bool Source #