Safe Haskell | None |
---|---|
Language | Haskell2010 |
Read and write a record into JSON tree
Synopsis
- type ValuePrism a = APrism' Value a
- data JSOP p a = JSOP {
- jsop_path :: p
- jsop_default :: Maybe a
- jsop_prism :: ValuePrism a
- required :: p -> ValuePrism a -> JSOP p a
- optional :: p -> a -> ValuePrism a -> JSOP p a
- data JSOPIssue
- jread :: (All Typeable xs, IsProductType a xs) => (path -> [Text]) -> NP (JSOP path) xs -> Value -> Either JSOPIssue a
- paths :: All Top xs => NP (JSOP p) xs -> [p]
- parseSField :: forall a p. Typeable a => JSOP p a -> K (Int, Maybe Value) a -> Either JSOPIssue a
- type QPaths = Trie Text (First Int, [Int])
- mkPath :: Int -> [Text] -> QPaths
- mkPaths :: [[Text]] -> QPaths
- treequery :: QPaths -> Value -> ([(Int, Value)], [Int])
- getValues :: (p -> [Text]) -> [p] -> Value -> [Maybe Value]
- type TPaths = Trie Text (First Int, Any)
- mkTPath :: Int -> (Bool, [Text]) -> TPaths
- mkTPaths :: [(Bool, [Text])] -> TPaths
- treechange :: Bool -> TPaths -> Value -> Map Int Value -> Value
- setValues :: (p -> (Bool, [Text])) -> [(p, Value)] -> Value -> Value
- jwrite :: (All Typeable xs, IsProductType a xs, All Top xs, Show path, Ord path) => (path -> [Text]) -> NP (JSOP path) xs -> Value -> a -> Value
Documentation
A record field operation specification
JSOP | |
|
:: p | path |
-> ValuePrism a | prism |
-> JSOP p a |
shortcut for a parser that handle missing values
:: p | path |
-> a | default value |
-> ValuePrism a | prism |
-> JSOP p a |
shortcut for parsers that have a default if value is missing
parsing problems
:: (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
parseSField :: forall a p. Typeable a => JSOP p a -> K (Int, Maybe Value) a -> Either JSOPIssue a Source #
:: (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]
:: (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