#[repr(C)]pub struct yyjson_mut_obj_iter {
pub idx: usize,
pub max: usize,
pub cur: *mut yyjson_mut_val,
pub pre: *mut yyjson_mut_val,
pub obj: *mut yyjson_mut_val,
}
Expand description
A mutable JSON object iterator.
@warning You should not modify the object while iterating over it, but you can
use yyjson_mut_obj_iter_remove()
to remove current value.
@b Example @code yyjson_mut_val *key, *val; yyjson_mut_obj_iter iter = yyjson_mut_obj_iter_with(obj); while ((key = yyjson_mut_obj_iter_next(&iter))) { val = yyjson_mut_obj_iter_get_val(key); your_func(key, val); if (your_val_is_unused(key, val)) { yyjson_mut_obj_iter_remove(&iter); } } @endcode
If the ordering of the keys is known at compile-time, you can use this method
to speed up value lookups:
@code
// {“k1”:1, “k2”: 3, “k3”: 3}
yyjson_mut_val *key, *val;
yyjson_mut_obj_iter iter = yyjson_mut_obj_iter_with(obj);
yyjson_mut_val *v1 = yyjson_mut_obj_iter_get(&iter, “k1”);
yyjson_mut_val *v3 = yyjson_mut_obj_iter_get(&iter, “k3”);
@endcode
@see yyjson_mut_obj_iter_get()
and yyjson_mut_obj_iter_getn()
Fields§
§idx: usize
< next key’s index
max: usize
< maximum key index (obj.size)
cur: *mut yyjson_mut_val
< current key
pre: *mut yyjson_mut_val
< previous key
obj: *mut yyjson_mut_val
< the object being iterated
Trait Implementations§
Source§impl Clone for yyjson_mut_obj_iter
impl Clone for yyjson_mut_obj_iter
Source§fn clone(&self) -> yyjson_mut_obj_iter
fn clone(&self) -> yyjson_mut_obj_iter
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more