haste-compiler-0.5.5.0: Haskell To ECMAScript compiler

Safe HaskellNone
LanguageHaskell98

Haste.JSON

Description

Haste-specific JSON library. JSON is common enough that it's a good idea to create as fast and small an implementation as possible. To that end, the parser is implemented entirely in Javascript, and works with any browser that supports JSON.parse; IE does this from version 8 and up, and everyone else has done it since just about forever.

Synopsis

Documentation

data JSON

Constructors

Num !Double 
Str !JSString 
Bool !Bool 
Arr ![JSON] 
Dict ![(JSString, JSON)] 
Null 

Instances

Num JSON

This instance may be a bad idea, but it's nice to be able to create JSON objects using plain numeric literals.

Show JSON 
IsString JSON 
JSType JSON 
Serialize JSON 

toObject :: JSON -> JSAny

Create a JavaScript object from a JSON object. Only makes sense in a browser context, obviously.

(!) :: JSON -> JSString -> JSON infixl 5

Look up a JSON object from a JSON dictionary. Panics if the dictionary isn't a dictionary, or if it doesn't contain the given key.

(~>) :: JSONLookup a => a -> JSString -> Maybe JSON infixl 5

Look up a key in a JSON dictionary. Return Nothing if the key can't be found for some reason.