| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
JavaScript.JSON.Types.Internal
Contents
- newtype SomeValue m = SomeValue JSVal
- type Value = SomeValue Immutable
- type MutableValue = SomeValue Mutable
- data SomeValue' m
- type Value' = SomeValue' Immutable
- type MutableValue' = SomeValue' Mutable
- type MutableValue = SomeValue Mutable
- type MutableValue' = SomeValue' Mutable
- emptyArray :: Value
- isEmptyArray :: Value -> Bool
- type Pair = (JSString, Value)
- type Object = SomeObject Immutable
- type MutableObject = SomeObject Mutable
- objectProperties :: Object -> JSArray
- objectPropertiesIO :: SomeObject o -> IO JSArray
- objectAssocs :: Object -> [(JSString, Value)]
- objectAssocsIO :: SomeObject m -> IO [(JSString, Value)]
- class Lookup k a where
- class IOLookup k a where
- (^!) :: k -> a -> IO MutableValue
- lookupIO :: k -> a -> IO (Maybe MutableValue)
- lookupIO' :: k -> a -> IO (Maybe MutableValue')
- emptyObject :: Object
- match :: SomeValue m -> SomeValue' m
- arrayValue :: JSArray -> Value
- stringValue :: JSString -> Value
- doubleValue :: Double -> Value
- nullValue :: Value
- boolValue :: Bool -> Value
- objectValue :: Object -> Value
- arrayValueList :: [Value] -> JSArray
- indexV :: JSArray -> Int -> Value
- data Parser a :: * -> *
- data Result a :: * -> *
- parse :: (a -> Parser b) -> a -> Result b
- parseEither :: (a -> Parser b) -> a -> Either String b
- parseMaybe :: (a -> Parser b) -> a -> Maybe b
- modifyFailure :: (String -> String) -> Parser a -> Parser a
- encode :: Value -> JSString
- object :: [Pair] -> Object
- data Options :: * = Options {}
- data SumEncoding :: *
- defaultOptions :: Options
- defaultTaggedObject :: SumEncoding
- camelTo :: Char -> String -> String
- newtype DotNetTime :: * = DotNetTime {}
Core JSON types
type MutableValue = SomeValue Mutable Source
data SomeValue' m Source
type Value' = SomeValue' Immutable Source
type MutableValue' = SomeValue' Mutable Source
type MutableValue = SomeValue Mutable Source
type MutableValue' = SomeValue' Mutable Source
isEmptyArray :: Value -> Bool Source
type MutableObject = SomeObject Mutable Source
objectProperties :: Object -> JSArray Source
objectPropertiesIO :: SomeObject o -> IO JSArray Source
objectAssocs :: Object -> [(JSString, Value)] Source
objectAssocsIO :: SomeObject m -> IO [(JSString, Value)] Source
Methods
Arguments
| :: k | |
| -> a | |
| -> Value | throws when result is not a JSON value |
class IOLookup k a where Source
Methods
Arguments
| :: k | |
| -> a | |
| -> IO MutableValue | throws when result is not a JSON value |
Arguments
| :: k | |
| -> a | |
| -> IO (Maybe MutableValue) | returns Nothing when result is not a JSON value |
Arguments
| :: k | |
| -> a | |
| -> IO (Maybe MutableValue') | returns Nothing when result is not a JSON value |
match :: SomeValue m -> SomeValue' m Source
arrayValue :: JSArray -> Value Source
stringValue :: JSString -> Value Source
doubleValue :: Double -> Value Source
objectValue :: Object -> Value Source
arrayValueList :: [Value] -> JSArray Source
Type conversion
data Parser a :: * -> *
A JSON parser.
parseEither :: (a -> Parser b) -> a -> Either String b
parseMaybe :: (a -> Parser b) -> a -> Maybe b
modifyFailure :: (String -> String) -> Parser a -> Parser a
If the inner Parser failed, modify the failure message using the
provided function. This allows you to create more descriptive error messages.
For example:
parseJSON (Object o) = modifyFailure
("Parsing of the Foo value failed: " ++)
(Foo <$> o .: "someField")Since 0.6.2.0
Constructors and accessors
Generic and TH encoding configuration
data Options :: *
Options that specify how to encode/decode your datatype to/from JSON.
Constructors
| Options | |
Fields
| |
data SumEncoding :: *
Specifies how to encode constructors of a sum datatype.
Constructors
| TaggedObject | A constructor will be encoded to an object with a field
|
Fields | |
| ObjectWithSingleField | A constructor will be encoded to an object with a single
field named after the constructor tag (modified by the
|
| TwoElemArray | A constructor will be encoded to a 2-element array where the
first element is the tag of the constructor (modified by the
|
Instances
Default encoding Options:
Options{fieldLabelModifier= id ,constructorTagModifier= id ,allNullaryToStringTag= True ,omitNothingFields= False ,sumEncoding=defaultTaggedObject,unwrapUnaryRecords= False }
defaultTaggedObject :: SumEncoding
Default TaggedObject SumEncoding options:
defaultTaggedObject =TaggedObject{tagFieldName= "tag" ,contentsFieldName= "contents" }
Used for changing CamelCase names into something else.
camelTo :: Char -> String -> String
Converts from CamelCase to another lower case, interspersing
the character between all capital letters and their previous
entries, except those capital letters that appear together,
like API.
For use by Aeson template haskell calls.
camelTo '_' 'CamelCaseAPI' == "camel_case_api"
Other types
newtype DotNetTime :: *
A newtype wrapper for UTCTime that uses the same non-standard
serialization format as Microsoft .NET, whose
System.DateTime
type is by default serialized to JSON as in the following example:
/Date(1302547608878)/
The number represents milliseconds since the Unix epoch.
Constructors
| DotNetTime | |
Fields
| |