Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
- Methods
- boxedCanDeserialize
- boxedCanSerialize
- boxedDeserialize
- boxedSerialize
- constructGobject
- fromString
- gobjectDeserialize
- gobjectFromData
- gobjectSerialize
- gobjectToData
- gvariantDeserialize
- gvariantDeserializeData
- gvariantSerialize
- gvariantSerializeData
- serializeGobject
- stringCompare
- stringEqual
- stringHash
- toString
Synopsis
- boxedCanDeserialize :: (HasCallStack, MonadIO m) => GType -> NodeType -> m Bool
- boxedCanSerialize :: (HasCallStack, MonadIO m) => GType -> m (Bool, NodeType)
- boxedDeserialize :: (HasCallStack, MonadIO m) => GType -> Node -> m (Ptr ())
- boxedSerialize :: (HasCallStack, MonadIO m) => GType -> Ptr () -> m (Maybe Node)
- constructGobject :: (HasCallStack, MonadIO m) => GType -> Text -> Word64 -> m (Maybe Object)
- fromString :: (HasCallStack, MonadIO m) => Text -> m (Maybe Node)
- gobjectDeserialize :: (HasCallStack, MonadIO m) => GType -> Node -> m Object
- gobjectFromData :: (HasCallStack, MonadIO m) => GType -> Text -> Int64 -> m (Maybe Object)
- gobjectSerialize :: (HasCallStack, MonadIO m, IsObject a) => a -> m Node
- gobjectToData :: (HasCallStack, MonadIO m, IsObject a) => a -> m (Text, Word64)
- gvariantDeserialize :: (HasCallStack, MonadIO m) => Node -> Maybe Text -> m (Maybe GVariant)
- gvariantDeserializeData :: (HasCallStack, MonadIO m) => Text -> Int64 -> Maybe Text -> m (Maybe GVariant)
- gvariantSerialize :: (HasCallStack, MonadIO m) => GVariant -> m Node
- gvariantSerializeData :: (HasCallStack, MonadIO m) => GVariant -> m (Text, Word64)
- serializeGobject :: (HasCallStack, MonadIO m, IsObject a) => a -> m (Text, Word64)
- stringCompare :: (HasCallStack, MonadIO m) => Text -> Text -> m Int32
- stringEqual :: (HasCallStack, MonadIO m) => Text -> Text -> m Bool
- stringHash :: (HasCallStack, MonadIO m) => Text -> m Word32
- toString :: (HasCallStack, MonadIO m) => Node -> Bool -> m Text
Methods
boxedCanDeserialize
:: (HasCallStack, MonadIO m) | |
=> GType |
|
-> NodeType |
|
-> m Bool | Returns: |
Checks whether it is possible to deserialize a GBoxed
of
type gboxed_type
from a [structjson
.Node] of type node_type
.
Since: 0.10
boxedCanSerialize
:: (HasCallStack, MonadIO m) | |
=> GType |
|
-> m (Bool, NodeType) | Returns: |
Checks whether it is possible to serialize a GBoxed
of
type gboxed_type
into a [structjson
.Node].
The type of the node is placed inside node_type
if the function
returns TRUE
, and it's undefined otherwise.
Since: 0.10
boxedDeserialize
:: (HasCallStack, MonadIO m) | |
=> GType |
|
-> Node |
|
-> m (Ptr ()) | Returns: the newly allocated boxed data |
Deserializes the given [structjson
.Node] into a GBoxed
of the given type.
Since: 0.10
boxedSerialize
:: (HasCallStack, MonadIO m) | |
=> GType |
|
-> Ptr () |
|
-> m (Maybe Node) | Returns: a node with the serialized boxed type |
Serializes a pointer to a GBoxed
of the given type into a [structjson
.Node].
If the serialization is not possible, this function will return NULL
.
Since: 0.10
constructGobject
:: (HasCallStack, MonadIO m) | |
=> GType |
|
-> Text |
|
-> Word64 |
|
-> m (Maybe Object) | Returns: a new object instance of the given type (Can throw |
Deprecated: (Since version 0.10)Use [funcjson
.gobject_from_data] instead
Deserializes a JSON data stream and creates an instance of the given type
If the given type implements the [ifacejson
.Serializable] interface, it
will be asked to deserialize all the JSON members into their respective
properties; otherwise, the default implementation will be used to translate
the compatible JSON native types.
- *Note**: the JSON data stream must be an object.
Since: 0.4
fromString
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m (Maybe Node) | Returns: the root node of the JSON tree (Can throw |
Parses the given string and returns the corresponding JSON tree.
If the string is empty, this function will return NULL
.
In case of parsing error, this function returns NULL
and sets
the error appropriately.
Since: 1.2
gobjectDeserialize
:: (HasCallStack, MonadIO m) | |
=> GType |
|
-> Node |
|
-> m Object | Returns: The newly created instance |
Creates a new GObject
instance of the given type, and constructs it
using the members of the object in the given node.
Since: 0.10
gobjectFromData
:: (HasCallStack, MonadIO m) | |
=> GType |
|
-> Text |
|
-> Int64 |
|
-> m (Maybe Object) | Returns: a new object instance of the given type (Can throw |
Deserializes a JSON data stream and creates an instance of the given type.
If the type implements the [ifacejson
.Serializable] interface, it will
be asked to deserialize all the JSON members into their respective properties;
otherwise, the default implementation will be used to translate the
compatible JSON native types.
- *Note**: the JSON data stream must be an object
Since: 0.10
gobjectSerialize
:: (HasCallStack, MonadIO m, IsObject a) | |
=> a |
|
-> m Node | Returns: the newly created JSON tree |
Creates a JSON tree representing the passed object instance.
Each member of the returned JSON object will map to a property of the object type.
The returned JSON tree will be returned as a JsonNode
with a type
of JSON_NODE_OBJECT
.
Since: 0.10
gobjectToData
:: (HasCallStack, MonadIO m, IsObject a) | |
=> a |
|
-> m (Text, Word64) | Returns: a JSON data stream representing the given object |
Serializes a GObject
instance into a JSON data stream, iterating
recursively over each property.
If the given object implements the [ifacejson
.Serializable] interface,
it will be asked to serialize all its properties; otherwise, the default
implementation will be use to translate the compatible types into
JSON native types.
Since: 0.10
gvariantDeserialize
:: (HasCallStack, MonadIO m) | |
=> Node |
|
-> Maybe Text |
|
-> m (Maybe GVariant) | Returns: A newly created |
Converts a JSON data structure to a GVariant
.
If signature
is not NULL
, it will be used to resolve ambiguous
data types.
If no error occurs, the resulting GVariant
is guaranteed to conform
to signature
.
If signature
is not NULL
but does not represent a valid GVariant
type
string, NULL
is returned and the error
is set to
G_IO_ERROR_INVALID_ARGUMENT
.
If a signature
is provided but the JSON structure cannot be mapped to it,
NULL
is returned and the error
is set to G_IO_ERROR_INVALID_DATA
.
If signature
is NULL
, the conversion is done based strictly on the types
in the JSON nodes.
The returned variant has a floating reference that will need to be sunk by the caller code.
Since: 0.14
gvariantDeserializeData
gvariantDeserializeData Source #
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> Int64 |
|
-> Maybe Text |
|
-> m (Maybe GVariant) | Returns: A newly created |
Converts a JSON string to a GVariant
value.
This function works exactly like [funcjson
.gvariant_deserialize], but
takes a JSON encoded string instead.
The string is first converted to a [structjson
.Node] using
[classjson
.Parser], and then json_gvariant_deserialize
is called on
the node.
The returned variant has a floating reference that will need to be sunk by the caller code.
Since: 0.14
gvariantSerialize
:: (HasCallStack, MonadIO m) | |
=> GVariant |
|
-> m Node | Returns: the root of the JSON data structure
obtained from |
Converts variant
to a JSON tree.
Since: 0.14
gvariantSerializeData
gvariantSerializeData Source #
:: (HasCallStack, MonadIO m) | |
=> GVariant |
|
-> m (Text, Word64) | Returns: The JSON encoded string corresponding to the given variant |
Converts variant
to its JSON encoded string representation.
This is a convenience function around [funcjson
.gvariant_serialize], to
obtain the JSON tree, and then [classjson
.Generator] to stringify it.
Since: 0.14
serializeGobject
:: (HasCallStack, MonadIO m, IsObject a) | |
=> a |
|
-> m (Text, Word64) | Returns: a JSON data stream representing the given object |
Deprecated: (Since version 0.10)Use [funcjson
.gobject_to_data] instead
Serializes a GObject
instance into a JSON data stream.
If the object implements the [ifacejson
.Serializable] interface, it will be
asked to serizalize all its properties; otherwise, the default
implementation will be use to translate the compatible types into JSON
native types.
stringCompare
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> Text |
|
-> m Int32 | Returns: an integer less than zero if |
Check whether a
and b
are equal UTF-8 JSON strings and return an ordering
over them in strcmp()
style.
Since: 1.2
stringEqual
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> Text |
|
-> m Bool | Returns: |
Check whether a
and b
are equal UTF-8 JSON strings.
Since: 1.2
stringHash
:: (HasCallStack, MonadIO m) | |
=> Text |
|
-> m Word32 | Returns: hash value for |
Calculate a hash value for the given key
(a UTF-8 JSON string).
Note: Member names are compared byte-wise, without applying any Unicode decomposition or normalisation. This is not explicitly mentioned in the JSON standard (ECMA-404), but is assumed.
Since: 1.2