AttoJson-0.5.3: Simple lightweight JSON parser, generator & manipulator based on ByteString

Text.JSON.AttoJSON

Contents

Synopsis

Class and Data-Types for JSON Value

data JSValue Source

Data types for JSON value.

Constructors

JSString

JSON String

JSNumber Rational

JSON Number

JSObject (Map ByteString JSValue)

JSON Object

JSArray [JSValue]

JSON Array

JSBool !Bool

JSON Bool

JSNull

JSON Null

class JSON a whereSource

Type Class for the value that can be converted from/into JSValue.

Methods

fromJSON :: JSValue -> Maybe aSource

Decode from JSValue

toJSON :: a -> JSValueSource

Encode into JSValue

Instances

Parsing & Printing

parseJSON :: ByteString -> Either String JSValueSource

Parse JSON source. Returns JSValue (Right) if succeed, Returns Left if faild.

showJSON :: JSValue -> ByteStringSource

Print JSValue as JSON source (not pretty).

Manipulating Objects

getField :: JSON a => ByteString -> JSValue -> Maybe aSource

Get the value for field in Object and decode it.

getFields :: JSON a => [ByteString] -> JSValue -> Maybe aSource

Same as getField but it can process nested Object. ex:

   getFeilds ["user", "name"] (JSObject [("user", JSObject [("name", JSString "hoge")])]) == Just "hoge"

updateField :: JSON a => ByteString -> a -> JSValue -> JSValueSource

Update or Insert the value for field in Object.