json-query-0.2.3.1: Kitchen sink for querying JSON
Safe HaskellSafe-Inferred
LanguageHaskell2010

Json.Path

Synopsis

Documentation

data Path Source #

A path to an object.

Constructors

Key !ShortText !Path

JSON path element of a key into an object, "object.key".

Index !Int !Path

JSON path element of an index into an array, "array[index]". Negative numbers result in undefined behavior.

Nil 

Instances

Instances details
Show Path Source # 
Instance details

Defined in Json.Path

Methods

showsPrec :: Int -> Path -> ShowS #

show :: Path -> String #

showList :: [Path] -> ShowS #

Eq Path Source # 
Instance details

Defined in Json.Path

Methods

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

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

Encoding

encode :: Path -> ShortText Source #

Encode a path.

>>> encode (Key "foo" $ Index 5 $ Key "bar" $ Nil)

Lookup

query :: Path -> Value -> Maybe Value Source #

Search for an element at the given path. Returns Nothing if anything in the path is missing.

query' :: Path -> Value -> Value Source #

Variant of query that returns Null if anything in the path is missing.

Reverse