Popularity
3.6
Declining
Activity
0.0
Stable
2
4
1

Monthly Downloads: 9
Programming language: Haskell
License: MIT License
Tags: Data     JSON    

json-fu alternatives and similar packages

Based on the "json" category.
Alternatively, view json-fu alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of json-fu or a related project?

Add another 'json' Package

README

json-fu: Generic JSON serialization / deserialization

Requires

{-# LANGUAGE DeriveDataTypeable #-}

import Data.Data
import Data.ByteString (ByteString)
import Data.JSON

Converts fields into snake_case

data Person = Person {
  firstName :: String
, lastName  :: String
, age       :: Int
} deriving (Eq, Show, Data, Typeable)

person :: ByteString
person = toJSON (Person "John" "Doe" 23)

This will resutl in JSON that is equivalent to:

{
  "first_name":"John",
  "last_name": "Doe",
  "age": 23
}

parseJSON person >>= fromJSON :: Maybe Person can be used to recover the original data type.

Strips constructor name from fields

data Message = Message {
  messageBody     :: String
, messageBodySize :: Int
} deriving (Eq, Show, Data, Typeable)

message :: ByteString
message = toJSON (Message "foobar" 6)

This will resutl in JSON that is equivalent to:

{
  "body": "foobar",
  "body_size": 6
}

parseJSON message >>= fromJSON :: Maybe Message can be used to recover the original data type.