Maintainer | Toshio Ito <debug.ito@gmail.com> |
---|---|
Safe Haskell | None |
Language | Haskell2010 |
- data GraphSON v = GraphSON {}
- class GraphSONTyped a where
- nonTypedGraphSON :: v -> GraphSON v
- typedGraphSON :: GraphSONTyped v => v -> GraphSON v
- typedGraphSON' :: Text -> v -> GraphSON v
- parseTypedGraphSON :: (GraphSONTyped v, FromJSON v) => Value -> Parser (GraphSON v)
Type
Wrapper for "typed JSON object" introduced in GraphSON version 2. See http://tinkerpop.apache.org/docs/current/dev/io/#graphson
This data type is useful for encoding/decoding GraphSON text.
>>>
Aeson.decode "1000" :: Maybe (GraphSON Int32)
Just (GraphSON {gsonType = Nothing, gsonValue = 1000})>>>
Aeson.decode "{\"@type\": \"g:Int32\", \"@value\": 1000}" :: Maybe (GraphSON Int32)
Just (GraphSON {gsonType = Just "g:Int32", gsonValue = 1000})
Functor GraphSON Source # | |
Foldable GraphSON Source # | |
Traversable GraphSON Source # | |
Eq v => Eq (GraphSON v) Source # | |
Ord v => Ord (GraphSON v) Source # | |
Show v => Show (GraphSON v) Source # | |
ToJSON v => ToJSON (GraphSON v) Source # | If |
FromJSON v => FromJSON (GraphSON v) Source # | If the given |
class GraphSONTyped a where Source #
Types that have an intrinsic type ID for gsonType
field.
gsonTypeFor :: a -> Text Source #
Type ID for gsonType
.
GraphSONTyped Char Source # | |
GraphSONTyped Double Source # | |
GraphSONTyped Float Source # | |
GraphSONTyped Int8 Source # | Map to "gx:Byte". Note that Java's Byte is signed. |
GraphSONTyped Int16 Source # | |
GraphSONTyped Int32 Source # | |
GraphSONTyped Int64 Source # | |
GraphSONTyped Scientific Source # | Map to "g:Double". |
GraphSONTyped [a] Source # | |
GraphSONTyped (HashSet a) Source # | |
GraphSONTyped (HashMap k v) Source # | Note that Lazy HashMap and Strict HashMap are the same data type. |
Constructors
nonTypedGraphSON :: v -> GraphSON v Source #
typedGraphSON :: GraphSONTyped v => v -> GraphSON v Source #
Create a GraphSON
with its type ID.
>>>
typedGraphSON (10 :: Int32)
GraphSON {gsonType = Just "g:Int32", gsonValue = 10}
typedGraphSON' :: Text -> v -> GraphSON v Source #
Create a GraphSON
with the given type ID.
>>>
typedGraphSON' "g:Int32" (10 :: Int)
GraphSON {gsonType = Just "g:Int32", gsonValue = 10}
Parser support
parseTypedGraphSON :: (GraphSONTyped v, FromJSON v) => Value -> Parser (GraphSON v) Source #
Parse GraphSON v
, but it checks gsonType
. If gsonType
is
Nothing
or it's not equal to gsonTypeFor
, the Parser
fails.