úÎ!OOKJ      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHI(c) Scrive 20114BSD-style (see the LICENSE file in the distribution)mariusz@scrive.com developmentportableNone=>?M6@  fields-json+Structures that can be matched with JSValue fields-jsonStructures that can be parsed] from JSON, fields absent in the JSON will be filled in using (optional) original structure.dBy convention JSON null should be treated as a request to reset structure element to default value. fields-jsonStructures that can be parsed+ from JSON. Instances must declare either  (parse directly from J) or  (uses K).Example implementation: ¬data D = D String Int instance FromJSValue D where fromJSValue = do s <- fromJSValueField "string_key" i <- fromJSValueField "int_key" return (D <$> s <*> i)Note that we make use of K instance for "(->)" and of  programming style with  and .Note:  is deprecated, in future % will be generalized to work in any K J.  fields-json1Reading the value that is on some field. Returns L} if JSON is not an object or field is present but cannot be parsed, 'Just Nothing' if absent, and 'Just (Just a)' otherwise  fields-jsoniReading the value that is on a field. Semantics are a bit involved, example GHCi session should clarify: ÿmPrelude> :set -XNoMonomorphismRestriction Prelude> let x = withJSValue (JSObject (toJSObject [("key",JSString $ toJSString "value")])) Prelude> x (fromJSValueField "key") :: IO (Maybe Int) Nothing Prelude> x (fromJSValueField "key") :: IO (Maybe (Maybe Int)) Just Nothing Prelude> x (fromJSValueField "key") :: IO (Maybe (Maybe (Maybe Int))) Just (Just Nothing) Prelude> x (fromJSValueField "key") :: IO (Maybe String) Just "value" Prelude> x (fromJSValueField "key") :: IO (Maybe (Maybe String)) Just (Just "value") Prelude> x (fromJSValueField "key") :: IO (Maybe (Maybe (Maybe String))) Just (Just (Just "value")) Prelude> let x = withJSValue (JSArray []) Prelude> x (fromJSValueField "key") :: IO (Maybe String) Nothing Prelude> x (fromJSValueField "key") :: IO (Maybe (Maybe String)) Nothing Prelude> x (fromJSValueField "key") :: IO (Maybe (Maybe (Maybe String))) Nothing  fields-json Version of  / for Base64 encoded data to avoid memory leak.  fields-jsonGeneralization of  . Does not use  instances.  fields-jsonQRuns parser on each element of underlaying json. Returns Just iff JSON is array. fields-jsonGeneralization of  9, where each element of array can have different parser. fields-json8Runs parser on each element of underlying json. Returns M iff JSON is an array.rNote: This method has quadratic complexity. It is better to write less general matching algorithms that use Maps. fields-jsonSimple runner. Example: Alet (v :: MyStruct) = runIdentity $ withJSValue js (fromJSValueM) or inline: Çlet z = runIdentity $ withJSValue js $ do a <- fromJSValueField "a" b <- fromJSValueField "b" c <- fromJSValueField "c" return ((,,) <$> a <*> b <*> c)or using the monad transformer: ¶z <- withJSValue js $ do a <- fromJSValueField "a" b <- fromJSValueField "b" c <- fromJSValueField "c" return ((,,) <$> a <*> b <*> c) fields-json%Parsing any Maybe always returns Just  (c) Scrive 20114BSD-style (see the LICENSE file in the distribution)mariusz@scrive.com developmentportableNone=>?M8Ã'('((c) Scrive 20114BSD-style (see the LICENSE file in the distribution)andrzej@scrive.com developmentportableNone=>?MJ·= fields-json.A monad that keeps currently constructed JSON.> fields-json Basic types? fields-jsonRunner. Example: 5let js = runJSONGen $ do value "abc" "def"@ fields-json%Runner as monad transformer. Example: Xjs <- runJSONGenT $ do d <- lift $ getFromOuterMonad value "abc" dA fields-json>Set pure value under given name in final JSON object. Example: value "key" "value"B fields-jsonMonadic verion of A" using monad transformer. Example: 6js <- runJSONGenT $ do valueM "abc" (getLine)C fields-jsonEEmbed other JSON object as field in a resulting JSON object. Example: Ylet js = runJSONGen $ do object "nested" $ do value "abc" "def"D fields-json&Version for lists of objects. Example: ÿ let js = runJSONGen $ do objects "nested" [ do value "abc" "def" value "x" "y", do value "qwe" "rty" ] '(=>?@ABCD>=?@ABCDN      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[YZ\]*fields-json-0.4.0.0-3bbIcfju5kx8oEqxOTEi3IText.JSON.FromJSValueText.JSON.ToJSValue Text.JSON.GenControl ApplicativeControl.Applicative<$><*>MatchWithJSValuematchesWithJSValuematchesWithJSValueMFromJSValueWithUpdatefromJSValueWithUpdatefromJSValueWithUpdateM FromJSValue fromJSValue fromJSValueM jsValueFieldfromJSValueFieldfromJSValueFieldBase64fromJSValueFieldCustomfromJSValueCustomManyfromJSValueCustomListfromJSValueManyWithUpdate withJSValue$fFromJSValue(,,,,,)$fFromJSValue(,,,,)$fFromJSValue(,,,)$fFromJSValue(,,)$fFromJSValue(,)$fFromJSValueMaybe$fFromJSValue[]$fFromJSValueFloat$fFromJSValueDouble$fFromJSValueBool$fFromJSValueWord64$fFromJSValueWord32$fFromJSValueWord16$fFromJSValueWord$fFromJSValueInt64$fFromJSValueInt32$fFromJSValueInt16$fFromJSValueInt$fFromJSValueInteger$fFromJSValueByteString$fFromJSValue[]0$fFromJSValueJSValue ToJSValue toJSValue$fToJSValue(,)$fToJSValueMaybe$fToJSValueMap $fToJSValue[]$fToJSValueFloat$fToJSValueDouble$fToJSValueWord64$fToJSValueWord32$fToJSValueWord16$fToJSValueWord8$fToJSValueWord$fToJSValueInt64$fToJSValueInt32$fToJSValueInt16$fToJSValueInt8$fToJSValueInt$fToJSValueInteger$fToJSValue[]0$fToJSValueBool$fToJSValueJSValueJSONGenTJSONGen runJSONGen runJSONGenTvaluevalueMobjectobjects$fMonadIOJSONGenT$fApplicativeJSONGenT$fFunctorJSONGenT$fMonadJSONGenT$fMonadTransJSONGenT!json-0.9.3-JvMhiyMMtQ8JrnGBiof0DyText.JSON.TypesJSValue mtl-2.2.2Control.Monad.Reader.Class MonadReaderbase GHC.MaybeNothingJust