gi-json-1.0.2: 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.ObjectIter

Description

An iterator object used to iterate over the members of a JSON object.

JsonObjectIter must be allocated on the stack and initialised using [methodjson.ObjectIter.init] or [methodjson.ObjectIter.init_ordered].

The iterator is invalidated if the object is modified during iteration.

All the fields in the JsonObjectIter structure are private and should never be accessed directly.

Since: 1.2

Synopsis

Exported types

newtype ObjectIter Source #

Memory-managed wrapper type.

newZeroObjectIter :: MonadIO m => m ObjectIter Source #

Construct a ObjectIter struct initialized to zero.

Methods

Click to display all available methods, including inherited ones

Expand

Methods

init, initOrdered, next, nextOrdered.

Getters

None.

Setters

None.

init

objectIterInit Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ObjectIter

iter: an uninitialised JSON object iterator

-> Object

object: the JSON object to iterate over

-> m () 

Initialises the iter and associate it with object.

``@c JsonObjectIter iter; const gchar *member_name; JsonNode *member_node;

json_object_iter_init (&iter, some_object); while (json_object_iter_next (&iter, &member_name, &member_node)) { // Do something with @member_name and @member_node. } @``

The iterator initialized with this function will iterate the members of the object in an undefined order.

See also: [methodjson.ObjectIter.init_ordered]

Since: 1.2

initOrdered

objectIterInitOrdered Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ObjectIter

iter: an uninitialised iterator

-> Object

object: the JSON object to iterate over

-> m () 

Initialises the iter and associate it with object.

``@c JsonObjectIter iter; const gchar *member_name; JsonNode *member_node;

json_object_iter_init_ordered (&iter, some_object); while (json_object_iter_next_ordered (&iter, &member_name, &member_node)) { // Do something with @member_name and @member_node. } @``

See also: [methodjson.ObjectIter.init]

Since: 1.6

next

objectIterNext Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ObjectIter

iter: a JSON object iterator

-> m (Bool, Text, Node)

Returns: TRUE if memberName and memberNode are valid; FALSE if there are no more members

Advances the iterator and retrieves the next member in the object.

If the end of the object is reached, FALSE is returned and memberName and memberNode are set to invalid values. After that point, the iter is invalid.

The order in which members are returned by the iterator is undefined. The iterator is invalidated if the object is modified during iteration.

You must use this function with an iterator initialized with [methodjson.ObjectIter.init]; using this function with an iterator initialized with [methodjson.ObjectIter.init_ordered] yields undefined behavior.

See also: [methodjson.ObjectIter.next_ordered]

Since: 1.2

nextOrdered

objectIterNextOrdered Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> ObjectIter

iter: an ordered JSON object iterator

-> m (Bool, Text, Node)

Returns: TRUE if memberName and memberNode are valid; FALSE if the end of the object has been reached

Advances the iterator and retrieves the next member in the object.

If the end of the object is reached, FALSE is returned and memberName and memberNode are set to invalid values. After that point, the iter is invalid.

The order in which members are returned by the iterator is the same order in which the members were added to the JsonObject. The iterator is invalidated if its JsonObject is modified during iteration.

You must use this function with an iterator initialized with [methodjson.ObjectIter.init_ordered]; using this function with an iterator initialized with [methodjson.ObjectIter.init] yields undefined behavior.

See also: [methodjson.ObjectIter.next]

Since: 1.6