json2 (empty) → 0.2
raw patch · 8 files changed
+753/−0 lines, 8 filesdep +basedep +containerssetup-changed
Dependencies added: base, containers
Files
- Data/JSON2.hs +279/−0
- Data/JSON2/FromSQL.hs +79/−0
- Data/JSON2/Query.hs +250/−0
- Examples/ExampleQuery.hs +42/−0
- Examples/ExampleSqlite.hs +44/−0
- LICENSE +31/−0
- Setup.hs +2/−0
- json2.cabal +26/−0
+ Data/JSON2.hs view
@@ -0,0 +1,279 @@+{-# Language TypeSynonymInstances, FlexibleInstances, IncoherentInstances #-}+module Data.JSON2+ (+ -- * Data types and classes+ Json(..), Jsons,+ ToJson(..), FromJson(..),+ -- * Building JSON objects+ emptyObj, singleObj, (==>), fromList,+ -- * Union JSON objects+ unionObj, unionsObj, unionRecObj,+ -- * Rendering to string+ toString,+ -- * Pretty print+ pprint, pprints+ ) +where++import Data.List+import qualified Data.Map as Map+import Data.Ratio++infixr 6 ==>++-- * Data types and classes++data Json = JString String+ | JNumber Rational+ | JBool Bool+ | JNull+ | JArray [Json]+ | JObject (Map.Map String Json) deriving (Eq, Show, Read)++type Jsons = [Json]++-- | This module provides instances @ToJson@ for :+-- @(), Char, Json, Maybe, Bool, String, Integr, Int, Double, Float,+-- Rational, Map String a, List, tuples 2-5 sizes@ .+--+-- Example :+--+-- > table :: [(Int, Maybe String, Bool)]+-- > table = [+-- > (1, Just "One", False),+-- > (2, Nothing, True)+-- > ]+-- > jTable = toJson table+-- > pprint jTable+-- > [[1, "One", false], [2, null, true]]+class ToJson a where+ toJson :: a -> Json++-- | This module provides instances @FromJson@ for :+-- @Json, Maybe, Bool, String, Integr, Int, Double, Float,+-- Rational, Map String a, List, tuples 2-5 sizes@ .+--+-- Example :+--+-- > fromJson jTable :: [(Double, Maybe String, Bool)]+-- > [(1.0, Just "One", False), (2.0, Nothing, True)]+class FromJson a where+ fromJson :: Json -> a++-- ** Instances FromJson and ToJson++instance ToJson () where+ toJson () = JArray []++instance ToJson Char where+ toJson x = JString [x]++instance ToJson Json where+ toJson = id+instance FromJson Json where+ fromJson = id++instance ToJson a => ToJson (Maybe a) where+ toJson = maybe JNull toJson+instance FromJson a => FromJson (Maybe a) where+ fromJson x = if x == JNull then Nothing else Just (fromJson x)++instance ToJson Bool where+ toJson x = JBool x+instance FromJson Bool where+ fromJson (JBool x) = x++instance ToJson String where+ toJson x = JString x+instance FromJson String where+ fromJson (JString x) = x++instance ToJson Integer where+ toJson = jsonifyIntegral+instance FromJson Integer where+ fromJson (JNumber i) = round i++instance ToJson Int where+ toJson = jsonifyIntegral+instance FromJson Int where+ fromJson (JNumber i) = round i++instance ToJson Double where+ toJson = jsonifyRealFrac+instance FromJson Double where+ fromJson (JNumber i) = fromRational i++instance ToJson Float where+ toJson = jsonifyRealFrac+instance FromJson Float where+ fromJson (JNumber i) = fromRational i++instance ToJson Rational where+ toJson = JNumber+instance FromJson Rational where+ fromJson (JNumber i) = i++instance (ToJson a) => ToJson (Map.Map String a) where+ toJson = JObject . Map.map toJson+instance (FromJson a) => FromJson (Map.Map String a) where+ fromJson (JObject m) = Map.map fromJson m++instance (ToJson a) => ToJson [a] where+ toJson = JArray . map toJson+instance (FromJson a) => FromJson [a] where+ fromJson (JArray xs) = map fromJson xs++instance (ToJson t1, ToJson t2) => ToJson (t1, t2) where+ toJson (x1, x2) = JArray [toJson x1, toJson x2]+instance (FromJson t1, FromJson t2) => FromJson (t1, t2) where+ fromJson (JArray [x, y]) = (fromJson x, fromJson y)+++instance (ToJson t1, ToJson t2, ToJson t3) => ToJson (t1, t2, t3) where+ toJson (x1, x2, x3) = JArray [toJson x1, toJson x2, toJson x3]+instance (FromJson t1, FromJson t2, FromJson t3) => FromJson (t1, t2, t3) where+ fromJson (JArray [x1, x2, x3]) = (fromJson x1, fromJson x2, fromJson x3)++instance (ToJson t1, ToJson t2, ToJson t3, ToJson t4) => ToJson (t1, t2, t3, t4) where+ toJson (x1, x2, x3, x4) = JArray [toJson x1, toJson x2, toJson x3, toJson x4]+instance (FromJson t1, FromJson t2, FromJson t3, FromJson t4) => FromJson (t1, t2, t3, t4) where+ fromJson (JArray [x1, x2, x3, x4]) = (fromJson x1, fromJson x2, fromJson x3, fromJson x4)++instance (ToJson t1, ToJson t2, ToJson t3, ToJson t4, ToJson t5) => ToJson (t1, t2, t3, t4, t5) where+ toJson (x1, x2, x3, x4, x5) = JArray [toJson x1, toJson x2, toJson x3, toJson x4, toJson x5]+instance (FromJson t1, FromJson t2, FromJson t3, FromJson t4, FromJson t5) => FromJson (t1, t2, t3, t4, t5) where+ fromJson (JArray [x1, x2, x3, x4, x5]) = (fromJson x1, fromJson x2, fromJson x3, fromJson x4, fromJson x5)+++-- * Building JSON objects++-- | Create empty JSON object.+emptyObj :: Json+emptyObj = JObject (Map.empty)++-- | Create single JSON object.+singleObj :: ToJson a => String -> a -> Json+singleObj k v = JObject (Map.singleton k (toJson v))++-- | @(`==>`)@ Eq @`singleObj`@ .+(==>) :: ToJson a => String -> a -> Json+(==>) = singleObj++-- | Create JSON object from list.+fromList :: ToJson a => [(String, a)] -> Json+fromList xs = JObject $ Map.fromList (map (\(k,v) -> (k, toJson v)) xs)++-- * Union JSON objects++-- | Merge two JSON Objects.+--+-- Example:+--+-- > objA = fromList [("a", toJson "1"), ("r", fromList [("ra", "11"), ("rb", "12")])]+-- > pprint objA+-- > {+-- > "a": "1",+-- > "r": {+-- > "ra": "11",+-- > "rb": "12"+-- > }+-- > }+-- > objB = fromList [("b", toJson "2"), ("r", fromList [("rb", "13"), ("rc", "14")])]+-- > pprint objB+-- > {+-- > "b": "2",+-- > "r": {+-- > "rb": "13",+-- > "rc": "14"+-- > }+-- > }+-- > pprint $ objA `unionObj` objB+-- > {+-- > "a": "1",+-- > "b": "2",+-- > "r": {+-- > "ra": "11",+-- > "rb": "12"+-- > }+-- > }+-- > +unionObj :: Json -> Json -> Json+unionObj (JObject x ) (JObject y) = JObject $ Map.union x y+unionObj x _ = x++-- | Merge JSON objects from list.+unionsObj :: [Json] -> Json+unionsObj xs = foldl unionObj emptyObj xs++-- | Recursive merge two JSON Objects.+--+-- Example :+--+-- > objR = objA `unionRecObj` objB+-- > pprint objR+-- > {+-- > "a": "1",+-- > "b": "2",+-- > "r": {+-- > "ra": "11",+-- > "rb": "12",+-- > "rc": "14"+-- > }+-- > }++unionRecObj :: Json -> Json -> Json+unionRecObj (JObject x) (JObject y) = JObject $+ Map.unionWith (\v1 v2 -> unionRecObj v1 v2) x y+unionRecObj x _ = x++-- * Renders JSON to String++-- | Renders JSON to String.+toString :: Json -> String+toString (JNumber r) + | denominator r == 1 = show (numerator r)+ | otherwise = show (fromRational r :: Double)+toString (JBool True) = "true"+toString (JBool False) = "false"+toString JNull = "null"+toString (JString s) = "\"" ++ escJStr s ++ "\""+toString (JArray vs) = "[" ++ (intercalate ", " $ map (toString) vs) ++ "]"+toString (JObject l) = "{" ++ (intercalate ", " $ map (\(k, v) -> toString (JString k) ++ ": " ++ toString v) (Map.toList l)) ++ "}"++-- * Pretty print++-- | Pretty-prints JSON.+pprint :: Json -> IO ()+pprint j = putStrLn $ pprint' " " 0 j++pprint' :: String -> Integer -> Json -> String++pprint' indenter levels (JArray xs) = "[" ++ (intercalate ", " $ map (pprint' indenter levels) xs) ++ "]"++pprint' indenter levels (JObject mp) = let+ currentIndent = (concat (genericReplicate levels indenter))+ in intercalate "\n" $ ["{", intercalate ",\n" (map (((currentIndent ++ indenter) ++) . (\(key, value) -> pprint' indenter levels (JString key) ++ ": " ++ pprint' indenter (levels + 1) value)) $ Map.toList mp), currentIndent ++ "}"]+pprint' _ _ a = toString a++-- | Pretty-prints JSONs.+pprints :: [Json] -> IO ()+pprints js = putStrLn $+ "[\n " ++ ( intercalate "," $ map (\j -> (pprint' " " 1 ) j) js) ++ "\n]"++------------- private functions ----------------------------------------------++jsonifyRealFrac i = JNumber (approxRational i 1e-666)+jsonifyIntegral i = JNumber (fromIntegral i % 1)++escJStr :: String -> String+escJStr = concat . map (escJChar)++escJChar c = case c of+ '\n' -> "\\n"+ '\b' -> "\\b"+ '\f' -> "\\f"+ '\t' -> "\\t"+ '\r' -> "\\r"+ '\\' -> "\\\\"+ '\"' -> "\\\""+ _ -> [c]
+ Data/JSON2/FromSQL.hs view
@@ -0,0 +1,79 @@+module Data.JSON2.FromSQL where+import Data.JSON2+import qualified Data.Map as Map++-- | Conversion SQL-like JSON array to tree-like JSON object with use column.+groupWithCol :: Json -> Json+groupWithCol (JArray xs) = merges $ map objHT xs where+ merges xs = foldl merge emptyObj xs+ merge (JObject x) (JObject y) = JObject $ Map.unionWith (jConcat) x y+ jConcat(JArray xs) (JArray ys) = JArray (xs ++ ys)+ objHT (JArray ((JString x):xs)) = singleObj x [xs]+ objHT (JArray (x:xs)) = singleObj (toString x) [xs]+ objHT _ = emptyObj+groupWithCol _ = emptyObj++-- | Conversion SQL-like JSON array to tree-like JSON object with use columns.+--+-- COMPLEX EXAMPLE :+--+-- > import Database.HDBC+-- > import Database.HDBC.Sqlite3+-- > import Data.JSON2+-- > +-- > dbName = "..."+-- > selectSql = "SELECT * from test"+-- > +-- > main = do+-- > conn <- connectSqlite3 dbName+-- > stmtSel <- prepare conn selectSql+-- > execute stmtSel []+-- > q <- sFetchAllRows stmtSel+-- > mapM print q+-- > -- [Just "A",Just "1",Just "Pupkin",Just "1"]+-- > -- [Just "A",Just "2",Just "Sidorov",Just "2"]+-- > -- [Just "B",Just "22",Just "Petrov",Just "3"]+-- > -- [Just "B",Just "22",Just "Ivanov",Just "4"]+-- > -- [Just "B",Just "22",Just "Golubev",Just "5"]+-- > -- [Just "B",Just "33",Just "Petrov",Just "6"]+-- > let json = toJson (q :: [[Maybe String]])+-- > pprint json+-- > -- [+-- > -- ["A", "1", "Pupkin", "1"],+-- > -- ["A", "2", "Sidorov", "2"],+-- > -- ["B", "22", "Petrov", "3"],+-- > -- ["B", "22", "Ivanov", "4"],+-- > -- ["B", "22", "Golubev", "5"],+-- > -- ["B", "33", "Petrov", "6"]+-- > -- ]+-- > let json' = groupWithNCol 2 json+-- > pprint json'+-- > -- {+-- > -- "A": {+-- > -- "1": [["Pupkin", "1"]],+-- > -- "2": [["Sidorov", "2"]]+-- > -- },+-- > -- "B": {+-- > -- "22": [["Petrov", "3"], ["Ivanov", "4"], ["Golubev", "5"]],+-- > -- "33": [["Petrov", "6"]]+-- > -- }+-- > -- }+-- > disconnect conn++groupWithNCol :: Int -> Json -> Json+groupWithNCol n j | n > 0 = mapj (n - 1) (groupWithCol j) + | otherwise = j+ where+ mapj n j@(JObject xs)+ | n > 0 = JObject ( Map.map ((mapj (n-1)) . groupWithCol) xs)+ | otherwise = j +{-+j0 = toJson ["a"]+j1 = toJson ["a", "aa", "aaa"]+j2 = toJson ["a", "ab", "abb"]+j3 = toJson ["a", "aa"]+j4 = toJson ["b", "bb", "bbb"]+j5 = toJson ["c", "87319827"]+j6 = toJson ["a", "ab", "abb"]+j7 = toJson ["a", "ab", "abb"]+-}
+ Data/JSON2/Query.hs view
@@ -0,0 +1,250 @@+-- | See also: <www.haskell.org/haskellwiki/HXT> +module Data.JSON2.Query+(+-- * Data Types+ JFilter+-- * Filtering+ ,isObj, isArr+ ,isStr ,isStrBy+ ,isNum ,isNumBy+ ,isBool, isTrue, isFalse+ ,isNull,isAtomic+ ,getFromObj, getFromKey, getFromKeys+ ,getFromArr ,getFromIndex ,getFromIndexes+ ,getChildern+-- * Filter Combinators+ ,(>>>) ,(<+>)+ ,orElse ,when ,guards+ ,deep, deepObj, deepArr+)+where+import qualified Data.Map as M (empty, singleton, unionWith, elems, union, lookup)+import qualified Data.Maybe as Mb (catMaybes)+import qualified Data.List as L (nub)+import Data.JSON2++type JFilter = Json -> Jsons++infixl 1 >>>+infixr 2 <+>++-- Fitering++-- | Filter JSON objects.+isObj :: JFilter+isObj (JObject o) = [JObject o]+isObj _ = []++-- | Filter JSON arrays.+isArr :: JFilter+isArr (JArray a) = [JArray a]+isArr _ = []++-- | Filter JSON strings.+isStr :: JFilter+isStr (JString s) = [JString s]+isStr _ = []++-- | Predicative filter JSON strings.+isStrBy :: (String -> Bool) -> JFilter+isStrBy p (JString s) = if p s then [JString s] else []+isStrBy _ _ = []++-- | Filter JSON numbers.+isNum :: JFilter+isNum (JNumber n) = [JNumber n]+isNum _ = []+++-- | Predicative filter JSON numbers.+isNumBy :: Fractional a => (a -> Bool) -> JFilter+isNumBy p (JNumber n) = if p (fromRational n) then [JNumber n] else []+isNumBy _ _ = []++-- | Filter JSON Bool.+isBool :: JFilter+isBool (JBool p) = [JBool p]+isBool _ = []++-- | Filter JSON True.+isTrue :: JFilter+isTrue (JBool True) = [JBool True]+isTrue _ = []++-- | Filter JSON False.+isFalse :: JFilter+isFalse (JBool False) = [JBool False]+isFalse _ = []++-- | Filter JSON null.+isNull :: JFilter+isNull JNull = [JNull]+isNull _ = []++-- | Filter primitive types.+isAtomic :: JFilter+isAtomic (JString s) = [JString s]+isAtomic (JNumber n) = [JNumber n]+isAtomic (JBool p) = [JBool p]+isAtomic JNull = [JNull]+isAtomic _ = []+++-- | Get elements from object with key.+getFromKey :: String -> JFilter+getFromKey k (JObject m) = Mb.catMaybes [(M.lookup k m)]+getFromKey _ _ = []++-- | Get elements from object with keys.+-- +-- Examles:+--+-- > citys :: Jsons+-- > citys =+-- > [+-- > "Europa" ==> "Ukraine" ==> ["Kiyv", "Gitomir", "Lviv"],+-- > "Asia" ==> "Japan" ==> ["Tokyo"],+-- > "Europa" ==> "UK" ==> ["London", "Glasgow"],+-- > "Europa" ==> "Germany" ==> ["Berlin", "Bonn"],+-- > "America" ==> "USA" ==> ["NewYork"],+-- > "America" ==> "Canada" ==> ["Toronto"],+-- > "Australia" ==> ["Melburn", "Adelaida"]+-- > ]+-- > jCitys = foldl unionRecObj emptyObj citys+-- > ex1 = pprint jCitys+-- > {+-- > "America": {+-- > "Canada": ["Toronto"],+-- > "USA": ["NewYork"]+-- > },+-- > "Asia": {+-- > "Japan": ["Tokyo"]+-- > },+-- > "Australia": ["Melburn", "Adelaida"],+-- > "Europa": {+-- > "Germany": ["Berlin", "Bonn"],+-- > "UK": ["London", "Glasgow"],+-- > "Ukraine": ["Kiyv", "Gitomir", "Lviv"]+-- > }+-- > }+-- > query2 = getFromKeys ["Europa", "America", "Atlantida"]+-- > ex2 = pprints $ query2 jCitys+-- > [+-- > {+-- > "Germany": ["Berlin", "Bonn"],+-- > "UK": ["London", "Glasgow"],+-- > "Ukraine": ["Kiyv", "Gitomir", "Lviv"]+-- > },{+-- > "Canada": ["Toronto"],+-- > "USA": ["NewYork"]+-- > }+-- > ]+getFromKeys :: [String] -> JFilter+getFromKeys ks (JObject m) = Mb.catMaybes $ map (\k -> (M.lookup k m)) (L.nub ks) +getFromKeys _ _ = []++-- | Get all elements from object.+getFromObj :: JFilter+getFromObj (JObject o) = M.elems o+getFromObj _ = []++-- | Get all elements from array.+getFromArr :: JFilter+getFromArr (JArray a) = a+getFromArr _ = []++-- | Get element from array with index.+getFromIndex :: Int -> JFilter+getFromIndex i (JArray a) = if i < length a then [a !! i] else []+getFromIndex _ _ = []++-- | Get elements from array with indexes.+getFromIndexes :: [Int] -> JFilter+getFromIndexes is ja = concat [getFromIndex i ja | i <- is]++-- | Get all elements from object and array.+getChildern :: JFilter+getChildern (JObject o) = M.elems o+getChildern (JArray a) = a+getChildern _ = []++-- Filter combinators++-- | @(f >>> g)@ - Apply filter f, later filter g .+--+-- Examples:+--+-- > query3 = getFromKeys ["Europa", "America"] >>> getFromObj +-- > ex3 = pprints $ query3 jCitys+--+-- Result:+--+-- > [+-- > ["Berlin", "Bonn"],["London", "Glasgow"],["Kiyv", "Gitomir", "Lviv"],["Toronto"],["NewYork"]+-- > ]+(>>>) :: JFilter -> JFilter -> JFilter +(f >>> g) t = concat [g t' | t' <- f t]++-- | Concat results two filters.+(<+>) :: JFilter -> JFilter -> JFilter+(f <+> g) t = f t ++ g t++-- | @(f `orElse` g)@ - Apply f, if @f@ returned @null@ apply @g@.+orElse :: JFilter -> JFilter -> JFilter+orElse f g t+ | null res1 = g t+ | otherwise = res1+ where res1 = f t++-- | @(f `when` g)@ - When @g@ returned @not null@, apply @f@.+when :: JFilter -> JFilter -> JFilter+when f g t+ | null (g t) = [t]+ | otherwise = f t+when' f g t = case g t of+ [] -> [t]+ _ -> f t+ +-- | @(f `guards` g )@ - If @f@ returned null then @null@ else apply @g@.+guards :: JFilter -> JFilter -> JFilter+guards f g t+ | null (f t) = []+ | otherwise = g t+++-- | Tree traversal filter for object and array.+deep :: JFilter -> JFilter+deep f = f `orElse` (getChildern >>> deep f)++-- | Tree traversal filter for array.+deepObj :: JFilter -> JFilter+deepObj f = f `orElse` (getFromObj >>> deepObj f)++-- | Tree traversal filter for array.+--+-- Example:+--+-- > -- Query: All city Europa and Australia.+-- > -- query31, query32, query33 is equal.+-- > +-- > query31 = getFromKeys ["Europa", "Australia"] +-- > >>> (getFromArr `orElse` getFromObj)+-- > >>> (isStr `orElse` getFromArr)+-- > ex31 = pprints $ query31 jCitys+-- > +-- > query32 = getFromKeys ["Europa", "Australia"] +-- > >>> (getFromObj `when` isObj)+-- > >>> getFromArr+-- > ex32 = pprints $ query32 jCitys+-- > +-- > query33 = getFromKeys ["Europa", "Australia"] +-- > >>> deep getFromArr+-- > ex33 = pprints $ query33 jCitys+--+-- Result:+--+-- > [+-- > "Berlin","Bonn","London","Glasgow","Kiyv","Gitomir","Lviv","Melburn","Adelaida"+-- > ]+deepArr :: JFilter -> JFilter+deepArr f = f `orElse` (getFromArr >>> deepArr f)
+ Examples/ExampleQuery.hs view
@@ -0,0 +1,42 @@+module Main where+import Data.JSON2+import Data.JSON2.Query++citys :: Jsons+citys =+ [+ "Europa" ==> "Ukraine" ==> ["Kiyv", "Gitomir", "Lviv"],+ "Asia" ==> "Japan" ==> ["Tokyo"],+ "Europa" ==> "UK" ==> ["London", "Glasgow"],+ "Europa" ==> "Germany" ==> ["Berlin", "Bonn"],+ "America" ==> "USA" ==> ["NewYork"],+ "America" ==> "Canada" ==> ["Toronto"],+ "Australia" ==> ["Melburn", "Adelaida"]+ ]+ex0 = pprints citys++jCitys = foldl unionRecObj emptyObj citys+ex1 = pprint jCitys++query2 = getFromKeys ["Europa", "America", "Atlantida"]+ex2 = pprints $ query2 jCitys++query3 = getFromKeys ["Europa", "America"] >>> getFromObj +ex3 = pprints $ query3 jCitys++ -- Query: All city Europa and Australia+ -- query31, query32, query33 is equal+ +query31 = getFromKeys ["Europa", "Australia"] + >>> (getFromArr `orElse` getFromObj)+ >>> (isStr `orElse` getFromArr)+ex31 = pprints $ query31 jCitys++query32 = getFromKeys ["Europa", "Australia"] + >>> (getFromObj `when` isObj)+ >>> getFromArr+ex32 = pprints $ query32 jCitys++query33 = getFromKeys ["Europa", "Australia"] + >>> deep getFromArr+ex33 = pprints $ query33 jCitys
+ Examples/ExampleSqlite.hs view
@@ -0,0 +1,44 @@+module Main where+import Database.HDBC+import Database.HDBC.Sqlite3+import Data.JSON2+import Data.JSON2.FromSQL++dbName = "Examples/test.db"+selectSql = "SELECT * from test"++main = do+ conn <- connectSqlite3 dbName+ stmtSel <- prepare conn selectSql+ execute stmtSel []+ q <- sFetchAllRows stmtSel+ mapM print q+ -- [Just "A",Just "1",Just "Pupkin",Just "1"]+ -- [Just "A",Just "2",Just "Sidorov",Just "2"]+ -- [Just "B",Just "22",Just "Petrov",Just "3"]+ -- [Just "B",Just "22",Just "Ivanov",Just "4"]+ -- [Just "B",Just "22",Just "Golubev",Just "5"]+ -- [Just "B",Just "33",Just "Petrov",Just "6"]+ let json = toJson (q :: [[Maybe String]])+ pprint json+ -- [+ -- ["A", "1", "Pupkin", "1"],+ -- ["A", "2", "Sidorov", "2"],+ -- ["B", "22", "Petrov", "3"],+ -- ["B", "22", "Ivanov", "4"],+ -- ["B", "22", "Golubev", "5"],+ -- ["B", "33", "Petrov", "6"]+ -- ]+ let json' = groupWithNCol 2 json+ pprint json'+ -- {+ -- "A": {+ -- "1": [["Pupkin", "1"]],+ -- "2": [["Sidorov", "2"]]+ -- },+ -- "B": {+ -- "22": [["Petrov", "3"], ["Ivanov", "4"], ["Golubev", "5"]],+ -- "33": [["Petrov", "6"]]+ -- }+ -- }+ disconnect conn
+ LICENSE view
@@ -0,0 +1,31 @@+Copyright (c) 2010, Yuriy Iskra+All rights reserved.++Redistribution and use in source and binary forms, with or without+modification, are permitted provided that the following conditions are+met:++ * Redistributions of source code must retain the above copyright+ notice, this list of conditions and the following disclaimer.++ * Redistributions in binary form must reproduce the above+ copyright notice, this list of conditions and the following+ disclaimer in the documentation and/or other materials provided+ with the distribution.++ * The names of its contributors may not be used to endorse or + promote products derived from this software without specific prior + written permission.++THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT+OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT+LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,+DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY+THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.+
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMain
+ json2.cabal view
@@ -0,0 +1,26 @@+Name: json2+Version: 0.2+Synopsis: This library provides support for JSON. +Category: Data, Text, JSON.+Description: This library provides support for JSON.+License: BSD3+License-file: LICENSE+Author: YuriyIskra <iskra.yw@gmail.com>+Maintainer: YuriyIskra <iskra.yw@gmail.com>+Stability: Experimental+Copyright: Copyright (c) 2011 Yuriy Iskra+Build-type: Simple+Cabal-version: >= 1.6++extra-source-files:+ Examples/ExampleSqlite.hs+ Examples/ExampleQuery.hs++library+ Exposed-modules: Data.JSON2+ Data.JSON2.FromSQL+ Data.JSON2.Query++ Build-Depends: base >= 4 && < 5,+ containers >= 0.2 && < 1+