norpan / elm-json-patch / Json.Patch

This module implements JSON Patch as per RFC 6902.

Types


type alias Patch =
List Operation

A Patch is a list of operations that are performed one after another.


type Operation
    = Add Json.Pointer.Pointer Json.Decode.Value
    | Remove Json.Pointer.Pointer
    | Replace Json.Pointer.Pointer Json.Decode.Value
    | Move Json.Pointer.Pointer Json.Pointer.Pointer
    | Copy Json.Pointer.Pointer Json.Pointer.Pointer
    | Test Json.Pointer.Pointer Json.Decode.Value

An operation, as defined by RFC 6902, section 4.

Operation

apply : Patch -> Json.Decode.Value -> Result String Json.Decode.Value

Apply a Patch to a Value

Operations are applied to the Value in order, and if one operation fails, the whole Patch fails, and an error is returned instead.

Encoder/Decoder

encoder : Patch -> Json.Encode.Value

JSON encoder for Patch

decoder : Json.Decode.Decoder Patch

JSON decoder for Patch