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

Safe HaskellNone
LanguageHaskell2010

Data.Aeson.Pointer

Contents

Description

 
Synopsis

Documentation

newtype Pointer Source #

Pointer to a location in a JSON document.

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

Constructors

Pointer 

Fields

Instances
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

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

data Key Source #

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

Constructors

OKey Text

Traverse a Value with an Value constructor.

AKey Int

Traverse a Value with an Value constructor.

Instances
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 #

ToJSON Key Source # 
Instance details

Defined in Data.Aeson.Pointer

FromJSON Key Source # 
Instance details

Defined in Data.Aeson.Pointer

type Path = [Key] Source #

A sequence of Keys forms a path through a JSON document.

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.