This is an alternative site for discovering Elm packages. You may be looking for the official Elm package site instead.
JSON Patch implementation
version 1.0.0
license BSD3
native-modules False
elm-version 0.18.0 <= v < 0.19.0
Tag 1.0.0
Committed At 2017-03-21 22:58:00 UTC
elm-lang/html 2.0.0 <= v < 3.0.0 2.0.0
elm-lang/core 5.1.1 <= v < 6.0.0 5.1.1
Skinney/elm-array-exploration 2.0.2 <= v < 3.0.0 2.0.5
NoRedInk/elm-decode-pipeline 3.0.0 <= v < 4.0.0 3.0.1

README

JSON Patch

This library implements [RFC 6902](https://tools.ietf.org/html/rfc6902 RFC6902), JSON Patch (and RFC 6901, JSON Pointer) for Elm.

Usage

Let's say you previously have gotten a JSON document as a Value from the server or via a port. Now you get a Value that is a JSON Patch for that document.

newDocument =
    Json.Decoder.decodeValue Json.Patch.decoder patch
        |> Result.andThen (\p -> Json.Patch.apply p document)

Patching needs to be done on the Value type, due to the type system (records can't be accessed by field name in Elm).

However, if you have an encoder/decoder pair for your Elm type, you can patch the Elm type like this:

newElmData =
    Json.Decoder.decodeValue Json.Patch.decoder patch
        |> Result.andThen
            (\p ->
                dataEncoder elmData
                    |> Json.Patch.apply p
                    |> Result.andThen (Json.Decoder.decodeValue dataDecoder)
            )