aeson-diff-1.1.0.13: Extract and apply patches to JSON documents.
Safe HaskellSafe-Inferred
LanguageHaskell2010

Data.Aeson.Pointer

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

Instances details
FromJSON Pointer Source # 
Instance details

Defined in Data.Aeson.Pointer

ToJSON Pointer Source # 
Instance details

Defined in Data.Aeson.Pointer

Monoid Pointer Source # 
Instance details

Defined in Data.Aeson.Pointer

Semigroup Pointer Source # 
Instance details

Defined in Data.Aeson.Pointer

Generic Pointer Source # 
Instance details

Defined in Data.Aeson.Pointer

Associated Types

type Rep Pointer :: Type -> Type #

Methods

from :: Pointer -> Rep Pointer x #

to :: Rep Pointer x -> Pointer #

Show Pointer Source # 
Instance details

Defined in Data.Aeson.Pointer

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

type Rep Pointer Source # 
Instance details

Defined in Data.Aeson.Pointer

type Rep Pointer = D1 ('MetaData "Pointer" "Data.Aeson.Pointer" "aeson-diff-1.1.0.13-4xcUBXffJWD3K6i4xKImYa" 'True) (C1 ('MetaCons "Pointer" 'PrefixI 'True) (S1 ('MetaSel ('Just "pointerPath") 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Path)))

data Key Source #

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

Constructors

OKey Key

Traverse a Value with an Object constructor.

AKey Int

Traverse a Value with an Array constructor.

Instances

Instances details
FromJSON Key Source # 
Instance details

Defined in Data.Aeson.Pointer

ToJSON Key Source # 
Instance details

Defined in Data.Aeson.Pointer

Generic Key Source # 
Instance details

Defined in Data.Aeson.Pointer

Associated Types

type Rep Key :: Type -> Type #

Methods

from :: Key -> Rep Key x #

to :: Rep Key x -> Key #

Show Key Source # 
Instance details

Defined in Data.Aeson.Pointer

Methods

showsPrec :: Int -> Key -> ShowS #

show :: Key -> String #

showList :: [Key] -> ShowS #

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 #

type Rep Key Source # 
Instance details

Defined in Data.Aeson.Pointer

type Rep Key = D1 ('MetaData "Key" "Data.Aeson.Pointer" "aeson-diff-1.1.0.13-4xcUBXffJWD3K6i4xKImYa" 'False) (C1 ('MetaCons "OKey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Key)) :+: C1 ('MetaCons "AKey" 'PrefixI 'False) (S1 ('MetaSel ('Nothing :: Maybe Symbol) 'NoSourceUnpackedness 'NoSourceStrictness 'DecidedLazy) (Rec0 Int)))

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.