-- Hoogle documentation, generated by Haddock -- See Hoogle, http://www.haskell.org/hoogle/ -- | Extends Text.JSON to handle literal JS objects. -- -- This module extends Text.JSON to enable the decoding of strings -- containing literal JS objects. @package json-litobj @version 0.1.0.0 -- | This module extends Text.JSON to enable the decoding of strings -- containing literal JS objects. In particular, it relaxes the -- restriction that fields in JSON objects must be strings. -- -- For example: -- --
-- JSON conformant: literal JS object:
-- { "foo" : "bar" } { foo : "bar" }
--
module Text.JSON.Permissive
-- | decodes a string encoding a JSON object in a relaxed fashion
--
--
-- decode "{ foo : \"bar\" }"
-- Error "Malformed JSON: expecting string: foo : \"b"
--
-- decodePermissive "{ foo : \"bar\" }" == Ok $ toJSObject [("foo", JSString $ toJSString "bar")]
-- decodePermissive "{ \"foo\" : \"bar\" }" == Ok $ toJSObject [("foo", JSString $ toJSString "bar")]
--
decodePermissive :: String -> Result (JSObject JSValue)
-- | returns the list of fields of a JSON Object
--
--
-- do obj <- decodePermissive "{ foo : \"bar\", fooz : \"baz\" }"
-- return $ get_fields obj == Ok ["foo", "fooz"]
--
--
--
-- do obj <- decodePermissive "{ foo : \"bar\", fooz : \"baz\" }"
-- return $ get_field obj $ head $ get_fields obj == Ok (Just $ JSString $ toJSString "bar" )
--
get_fields :: JSObject a -> [String]