jsop-0.2.0.1: Cherry picking in JSON objects

Safe HaskellNone
LanguageHaskell2010

Data.JSOP

Description

Read and write a record into JSON tree

Synopsis

Documentation

type ValuePrism a = APrism' Value a Source #

prism for a Value

data JSOP p a Source #

A record field operation specification

Constructors

JSOP 

Fields

required Source #

Arguments

:: p

path

-> ValuePrism a

prism

-> JSOP p a 

shortcut for a parser that handle missing values

optional Source #

Arguments

:: p

path

-> a

default value

-> ValuePrism a

prism

-> JSOP p a 

shortcut for parsers that have a default if value is missing

data JSOPIssue Source #

parsing problems

Constructors

JSOPIssue (Int, Maybe Value, TypeRep)

the index of the field in the record that failed, with the Value if reacheable and the requested type

JSOPWrongNumberOfPaths

paths are not enough or too many

Instances
Eq JSOPIssue Source # 
Instance details

Defined in Data.JSOP

Show JSOPIssue Source # 
Instance details

Defined in Data.JSOP

jread Source #

Arguments

:: (All Typeable xs, IsProductType a xs) 
=> (path -> [Text])

how to extract keys from a path

-> NP (JSOP path) xs

prisms for the path-indexed values

-> Value

json structure holding the record

-> Either JSOPIssue a

the record , if possible

get a record out of the json tree

paths :: All Top xs => NP (JSOP p) xs -> [p] Source #

parseSField :: forall a p. Typeable a => JSOP p a -> K (Int, Maybe Value) a -> Either JSOPIssue a Source #

treequery :: QPaths -> Value -> ([(Int, Value)], [Int]) Source #

getValues Source #

Arguments

:: (p -> [Text])

how to extract keys from a path

-> [p]

paths

-> Value

json tree

-> [Maybe Value]

found at path values

you should close over paths argument to get an efficient Value -> [Maybe Value]

setValues Source #

Arguments

:: (p -> (Bool, [Text]))

how to extract keys from paths, and if the path is required

-> [(p, Value)]

what to substitute at each path

-> Value

value to amend

-> Value

amended value

you should close over paths argument to get an efficient Value -> Value

jwrite Source #

Arguments

:: (All Typeable xs, IsProductType a xs, All Top xs, Show path, Ord path) 
=> (path -> [Text])

how to extract keys from a path

-> NP (JSOP path) xs

prisms for the path-indexed values

-> Value

json Value to amend

-> a

record to write

-> Value

amended Value

not very well defined write at path operation