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

Safe HaskellNone
LanguageHaskell2010

Data.Aeson.Pointer

Contents

Description

 

Synopsis

Documentation

data Key Source #

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

Constructors

OKey Text

Traverse a Value with an Object constructor.

AKey Int

Traverse a Value with an Array constructor.

Instances

Eq Key Source # 

Methods

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

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

Ord Key Source # 

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 # 

Methods

showsPrec :: Int -> Key -> ShowS #

show :: Key -> String #

showList :: [Key] -> ShowS #

ToJSON Key Source # 
FromJSON Key Source # 

Representing pointers

formatPointer :: Pointer -> Text Source #

Format a Pointer as described in RFC 6901.

>>> formatPointer (Pointer [])
""
>>> formatPointer (Pointer [OKey ""])
"/"
>>> formatPointer (Pointer [OKey " "])
"/ "
>>> formatPointer (Pointer [OKey "foo"])
"/foo"
>>> formatPointer (Pointer [OKey "foo", AKey 0])
"/foo/0"
>>> formatPointer (Pointer [OKey "a/b"])
"/a~1b"
>>> formatPointer (Pointer [OKey "c%d"])
"/c%d"
>>> formatPointer (Pointer [OKey "e^f"])
"/e^f"
>>> formatPointer (Pointer [OKey "g|h"])
"/g|h"
>>> formatPointer (Pointer [OKey "i\\j"])
"/i\\j"
>>> formatPointer (Pointer [OKey "k\"l"])
"/k\"l"
>>> formatPointer (Pointer [OKey "m~n"])
"/m~0n"

parsePointer :: Text -> Parser Pointer Source #

Parse a Pointer as described in RFC 6901.

Using pointers

get :: Pointer -> Value -> Result Value Source #

Follow a Pointer through a JSON document as described in RFC 6901.

pointerFailure :: Pointer -> Value -> Result a Source #

Report an error while following a pointer.