gi-json-1.0.3: JSON GObject bindings
CopyrightWill Thompson and Iñaki García Etxebarria
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Json.Structs.Object

Description

JsonObject is the representation of the object type inside JSON.

A JsonObject contains [structjson.Node] "members", which may contain fundamental types, arrays or other objects; each member of an object is accessed using a unique string, or "name".

Since objects can be arbitrarily big, copying them can be expensive; for this reason they are reference counted. You can control the lifetime of a JsonObject using objectRef and objectUnref.

To add or overwrite a member with a given name, use objectSetMember.

To extract a member with a given name, use objectGetMember.

To retrieve the list of members, use objectGetMembers.

To retrieve the size of the object (that is, the number of members it has), use objectGetSize.

Synopsis

Exported types

newtype Object Source #

Memory-managed wrapper type.

Constructors

Object (ManagedPtr Object) 

Instances

Instances details
Eq Object Source # 
Instance details

Defined in GI.Json.Structs.Object

Methods

(==) :: Object -> Object -> Bool #

(/=) :: Object -> Object -> Bool #

GBoxed Object Source # 
Instance details

Defined in GI.Json.Structs.Object

ManagedPtrNewtype Object Source # 
Instance details

Defined in GI.Json.Structs.Object

Methods

toManagedPtr :: Object -> ManagedPtr Object

TypedObject Object Source # 
Instance details

Defined in GI.Json.Structs.Object

Methods

glibType :: IO GType

HasParentTypes Object Source # 
Instance details

Defined in GI.Json.Structs.Object

IsGValue (Maybe Object) Source #

Convert Object to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Json.Structs.Object

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe Object -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe Object)

type ParentTypes Object Source # 
Instance details

Defined in GI.Json.Structs.Object

type ParentTypes Object = '[] :: [Type]

Methods

addMember

objectAddMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the member

-> Node

node: the value of the member

-> m () 

Deprecated: (Since version 0.8)Use objectSetMember instead

Adds a new member for the given name and value into an object.

This function will return if the object already contains a member with the same name.

dupMember

objectDupMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the JSON object member to access

-> m (Maybe Node)

Returns: a copy of the value for the requested object member

Retrieves a copy of the value of the given member inside an object.

Since: 0.6

equal

objectEqual Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

a: a JSON object

-> Object

b: another JSON object

-> m Bool

Returns: TRUE if a and b are equal, and FALSE otherwise

Check whether a and b are equal objects, meaning they have the same set of members, and the values of corresponding members are equal.

Since: 1.2

foreachMember

objectForeachMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> ObjectForeach

func: the function to be called on each member

-> m () 

Iterates over all members of object and calls func on each one of them.

It is safe to change the value of a member of the oobject from within the iterator function, but it is not safe to add or remove members from the object.

The order in which the object members are iterated is the insertion order.

Since: 0.8

getArrayMember

objectGetArrayMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the member

-> m (Maybe Array)

Returns: the array inside the object's member

Convenience function that retrieves the array stored in memberName of object. It is an error to specify a memberName which does not exist.

If memberName contains null, then this function will return NULL.

See also: objectGetMember, objectHasMember

Since: 0.8

getBooleanMember

objectGetBooleanMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the member

-> m Bool

Returns: the boolean value of the object's member

Convenience function that retrieves the boolean value stored in memberName of object. It is an error to specify a memberName which does not exist.

See also: objectGetBooleanMemberWithDefault, objectGetMember, objectHasMember

Since: 0.8

getBooleanMemberWithDefault

objectGetBooleanMemberWithDefault Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the object member

-> Bool

defaultValue: the value to return if memberName is not valid

-> m Bool

Returns: the boolean value of the object's member, or the given default

Convenience function that retrieves the boolean value stored in memberName of object.

If memberName does not exist, does not contain a scalar value, or contains null, then defaultValue is returned instead.

Since: 1.6

getDoubleMember

objectGetDoubleMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the member

-> m Double

Returns: the floating point value of the object's member

Convenience function that retrieves the floating point value stored in memberName of object. It is an error to specify a memberName which does not exist.

See also: objectGetDoubleMemberWithDefault, objectGetMember, objectHasMember

Since: 0.8

getDoubleMemberWithDefault

objectGetDoubleMemberWithDefault Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the object member

-> Double

defaultValue: the value to return if memberName is not valid

-> m Double

Returns: the floating point value of the object's member, or the given default

Convenience function that retrieves the floating point value stored in memberName of object.

If memberName does not exist, does not contain a scalar value, or contains null, then defaultValue is returned instead.

Since: 1.6

getIntMember

objectGetIntMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the object member

-> m Int64

Returns: the integer value of the object's member

Convenience function that retrieves the integer value stored in memberName of object. It is an error to specify a memberName which does not exist.

See also: objectGetIntMemberWithDefault, objectGetMember, objectHasMember

Since: 0.8

getIntMemberWithDefault

objectGetIntMemberWithDefault Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the object member

-> Int64

defaultValue: the value to return if memberName is not valid

-> m Int64

Returns: the integer value of the object's member, or the given default

Convenience function that retrieves the integer value stored in memberName of object.

If memberName does not exist, does not contain a scalar value, or contains null, then defaultValue is returned instead.

Since: 1.6

getMember

objectGetMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the JSON object member to access

-> m (Maybe Node)

Returns: the value for the requested object member

Retrieves the value of the given member inside an object.

getMembers

objectGetMembers Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> m [Text]

Returns: the member names of the object

Retrieves all the names of the members of an object.

You can obtain the value for each member by iterating the returned list and calling objectGetMember.

getNullMember

objectGetNullMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the member

-> m Bool

Returns: TRUE if the value is null

Convenience function that checks whether the value stored in memberName of object is null. It is an error to specify a memberName which does not exist.

See also: objectGetMember, objectHasMember

Since: 0.8

getObjectMember

objectGetObjectMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the member

-> m (Maybe Object)

Returns: the object inside the object's member

Convenience function that retrieves the object stored in memberName of object. It is an error to specify a memberName which does not exist.

If memberName contains null, then this function will return NULL.

See also: objectGetMember, objectHasMember

Since: 0.8

getSize

objectGetSize Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> m Word32

Returns: the number of members

Retrieves the number of members of a JSON object.

getStringMember

objectGetStringMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the member

-> m Text

Returns: the string value of the object's member

Convenience function that retrieves the string value stored in memberName of object. It is an error to specify a memberName that does not exist.

See also: objectGetStringMemberWithDefault, objectGetMember, objectHasMember

Since: 0.8

getStringMemberWithDefault

objectGetStringMemberWithDefault Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the object member

-> Text

defaultValue: the value to return if memberName is not valid

-> m Text

Returns: the string value of the object's member, or the given default

Convenience function that retrieves the string value stored in memberName of object.

If memberName does not exist, does not contain a scalar value, or contains null, then defaultValue is returned instead.

Since: 1.6

getValues

objectGetValues Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> m [Node]

Returns: the member values of the object

Retrieves all the values of the members of an object.

hasMember

objectHasMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of a JSON object member

-> m Bool

Returns: TRUE if the JSON object has the requested member

Checks whether object has a member named memberName.

hash

objectHash Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

key: a JSON object to hash

-> m Word32

Returns: hash value for key

Calculate a hash value for the given key (a JSON object).

The hash is calculated over the object and all its members, recursively. If the object is immutable, this is a fast operation; otherwise, it scales proportionally with the number of members in the object.

Since: 1.2

isImmutable

objectIsImmutable Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> m Bool

Returns: TRUE if the object is immutable

Checks whether the given object has been marked as immutable by calling objectSeal on it.

Since: 1.2

new

objectNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m Object

Returns: the newly created object

Creates a new object.

ref

objectRef Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> m Object

Returns: the given object, with the reference count increased by one.

Acquires a reference on the given object.

removeMember

objectRemoveMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the member to remove

-> m () 

Removes memberName from object, freeing its allocated resources.

seal

objectSeal Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> m () 

Seals the object, making it immutable to further changes.

This function will recursively seal all members of the object too.

If the object is already immutable, this is a no-op.

Since: 1.2

setArrayMember

objectSetArrayMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the member

-> Array

value: the value of the member

-> m () 

Convenience function for setting an object member with an array value.

See also: objectSetMember, nodeTakeArray

Since: 0.8

setBooleanMember

objectSetBooleanMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the member

-> Bool

value: the value of the member

-> m () 

Convenience function for setting an object member with a boolean value.

See also: objectSetMember, nodeInitBoolean

Since: 0.8

setDoubleMember

objectSetDoubleMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the member

-> Double

value: the value of the member

-> m () 

Convenience function for setting an object member with a floating point value.

See also: objectSetMember, nodeInitDouble

Since: 0.8

setIntMember

objectSetIntMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the member

-> Int64

value: the value of the member

-> m () 

Convenience function for setting an object member with an integer value.

See also: objectSetMember, nodeInitInt

Since: 0.8

setMember

objectSetMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the member

-> Node

node: the value of the member

-> m () 

Sets the value of a member inside an object.

If the object does not have a member with the given name, a new member is created.

If the object already has a member with the given name, the current value is overwritten with the new.

Since: 0.8

setNullMember

objectSetNullMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the member

-> m () 

Convenience function for setting an object member with a null value.

See also: objectSetMember, nodeInitNull

Since: 0.8

setObjectMember

objectSetObjectMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the member

-> Object

value: the value of the member

-> m () 

Convenience function for setting an object member with an object value.

See also: objectSetMember, nodeTakeObject

Since: 0.8

setStringMember

objectSetStringMember Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> Text

memberName: the name of the member

-> Text

value: the value of the member

-> m () 

Convenience function for setting an object member with a string value.

See also: objectSetMember, nodeInitString

Since: 0.8

unref

objectUnref Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> Object

object: a JSON object

-> m () 

Releases a reference on the given object.

If the reference count reaches zero, the object is destroyed and all its resources are freed.