- class TranslateField a where
- data TranslateFieldD a
- class TranslateField a => ToJson a where
- data ToJsonD a
- genericToJson :: (Data ToJsonD a, ToJson a, TranslateField a) => a -> JsonData
- enumToJson :: (Data ToJsonD a, ToJson a, TranslateField a) => (String -> String) -> a -> JsonData
- data JsonData
- class TranslateField a => FromJson a where
- data FromJsonD a
- parseJsonString :: String -> Either String JsonData
- parseJsonByteString :: ByteString -> Either String JsonData
- fromJsonString :: FromJson a => a -> String -> Either String a
- fromJsonByteString :: FromJson a => a -> ByteString -> Either String a
- genericFromJson :: (Data FromJsonD a, FromJson a, TranslateField a) => a -> JsonData -> Either String a
- enumFromJson :: (Data FromJsonD a, Data TranslateFieldD a) => (String -> String) -> a -> JsonData -> Either String a
- stripInitialUnderscores :: [Char] -> [Char]
- toJsonString :: ToJson a => a -> String
- firstCharToUpper :: String -> String
- firstCharToLower :: String -> String
- data Union a b = Union a b
- type Union3 a b c = Union (Union a b) c
- type Union4 a b c d = Union (Union3 a b c) d
- type Union5 a b c d e = Union (Union4 a b c d) e
- type Union6 a b c d e f = Union (Union5 a b c d e) f
- type Union7 a b c d e f g = Union (Union6 a b c d e f) g
- type Union8 a b c d e f g h = Union (Union7 a b c d e f g) h
- type Union9 a b c d e f g h i = Union (Union8 a b c d e f g h) i
- type Union10 a b c d e f g h i j = Union (Union9 a b c d e f g h i) j
This method defines the mapping from Haskell record field names to JSON object field names. The default is to strip any initial underscores. Specialize this method to define a different behavior.
New instances can be added to this class to customize certain aspects of the way in which Haskell types are serialized to JSON.
Applies to record types only. You can specialize this method to prevent certain fields from being serialized. Given a Haskell field name, it should return True if that field is to be serialized, and False otherwise.
Types that will be converted to JSON arrays can override this method to specify additional elements to be prepended to the array.
Types that will be converted to JSON arrays can override this method to specify additional elements to be appended to the array.
Types that will be converted to JSON objects can override this method to specify additional fields of the object.
This function is used as the the implementation of
toJson for the
generic instance declaration.
It's useful to be able to use the same implentation for
other instance declarations which override the default implementations
of other methods of the ToJson class.
This function can be used as an implementation of
toJson for simple enums.
It converts an enum value to a string determined by the name of the constructor,
after being fed through the (String -> String) function given as the first argument.
A Haskell representation of a JSON data structure.
|JDObject (Map String JsonData)|
To specify default values for the required fields of a JSON object, specialize this method in the instance definition for the relevant datatype.
Converts a String (interpreted as a true unicode String) to an instance of JsonData.
Converts a ByteString to an instance of JsonData (unicode encoding is detected automatically).
Converts a JSON String (interpreted as a true unicode string) to a value of the type given by the first (dummy) argument.
Converts a JSON ByteString (with unicode encoding automatically detected) to a value of the type given by the first (dummy) argument.
The counterpart of
This type can be used for merging two or more records together into a single JSON object. By default, a structure such as (Union X Y) is serialized as follows. First, X and Y are serialized, and a runtime error is signalled if the result of serialization is not a JSON object in both cases. The key/value pairs of the two JSON objects are then merged to form a single object.
|Union a b|
|(Data ctx a[a28u], Data ctx b[a28v], Sat (ctx (Union a[a28u] b[a28v]))) => Data ctx (Union a[a28u] b[a28v])|
|(Show a, Show b) => Show (Union a b)|
|(ToJson a, ToJson b, TranslateField a, TranslateField b, Typeable a, Typeable b, Typeable2 Union) => ToJson (Union a b)|
|(FromJson a, FromJson b, Typeable a, Typeable b, TranslateField a, TranslateField b) => FromJson (Union a b)|
Nested Unions are left-branching by convention (since this is what you get by using the constructor as an infix operator).