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.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 objectIterInit or objectIterInitOrdered.

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.

Constructors

ObjectIter (ManagedPtr ObjectIter) 

Instances

Instances details
Eq ObjectIter Source # 
Instance details

Defined in GI.Json.Structs.ObjectIter

BoxedPtr ObjectIter Source # 
Instance details

Defined in GI.Json.Structs.ObjectIter

CallocPtr ObjectIter Source # 
Instance details

Defined in GI.Json.Structs.ObjectIter

ManagedPtrNewtype ObjectIter Source # 
Instance details

Defined in GI.Json.Structs.ObjectIter

Methods

toManagedPtr :: ObjectIter -> ManagedPtr ObjectIter

tag ~ 'AttrSet => Constructible ObjectIter tag Source # 
Instance details

Defined in GI.Json.Structs.ObjectIter

Methods

new :: MonadIO m => (ManagedPtr ObjectIter -> ObjectIter) -> [AttrOp ObjectIter tag] -> m ObjectIter

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 code

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: objectIterInitOrdered

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 code

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: objectIterInit

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 objectIterInit; using this function with an iterator initialized with objectIterInitOrdered yields undefined behavior.

See also: objectIterNextOrdered

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 objectIterInitOrdered; using this function with an iterator initialized with objectIterInit yields undefined behavior.

See also: objectIterNext

Since: 1.6