CurryInfo: json-4.0.0 / JSON.Convert.ConvertJSON

definition: Info
 
class ConvertJSON a where
  -- | Convert a value into its JSON representation.
  toJSON :: a -> JValue

  -- | Convert a JSON representation into its corresponding value.
  fromJSON :: JValue -> Maybe a

  -- | Convert a list of values into its JSON rerpresentation.
  --   As a default, a JSON array is used to represent the list of values.
  toJSONList :: [a] -> JValue

  -- | Convert a JSON representation into the corresponding list of values.
  fromJSONList :: JValue -> Maybe [a]

  toJSONList = JArray . map toJSON

  fromJSONList jv = case jv of
    JArray xs -> let ys = map fromJSON xs
                 in if all isJust ys then Just (catMaybes ys)
                                     else Nothing
    _         -> Nothing
documentation: Info
 
| The type class `ConvertJSON` defines conversion operations
  between values and their JSON representation.
  Since a JSON value might not contain a correct representation
  of a standard value, the operation `fromJSON` returns a `Maybe` value.
  The additional operations on value lists are used for a better
  JSON conversion of strings.
methods: Info
 ["toJSON :: a -> JSON.Data.JValue","fromJSON :: JSON.Data.JValue -> Prelude.Maybe a","toJSONList 0 :: [a] -> JSON.Data.JValue","fromJSONList 1 :: JSON.Data.JValue -> Prelude.Maybe [a]"]
name: Info
 ConvertJSON