#[repr(C)]pub struct yyjson_ptr_ctx {
pub ctn: *mut yyjson_mut_val,
pub pre: *mut yyjson_mut_val,
pub old: *mut yyjson_mut_val,
}
Expand description
A context for JSON pointer operation.
This struct stores the context of JSON Pointer operation result. The struct
can be used with three helper functions: ctx_append()
, ctx_replace()
, and
ctx_remove()
, which perform the corresponding operations on the container
without re-parsing the JSON Pointer.
For example: @code // doc before: {“a”:[0,1,null]} // ptr: “/a/2” val = yyjson_mut_doc_ptr_getx(doc, ptr, strlen(ptr), &ctx, &err); if (yyjson_is_null(val)) { yyjson_ptr_ctx_remove(&ctx); } // doc after: {“a”:[0,1]} @endcode
Fields§
§ctn: *mut yyjson_mut_val
The container (parent) of the target value. It can be either an array or
an object. If the target location has no value, but all its parent
containers exist, and the target location can be used to insert a new
value, then ctn
is the parent container of the target location.
Otherwise, ctn
is NULL.
pre: *mut yyjson_mut_val
The previous sibling of the target value. It can be either a value in an
array or a key in an object. As the container is a circular linked list
of elements, pre
is the previous node of the target value. If the
operation is add
or set
, then pre
is the previous node of the new
value, not the original target value. If the target value does not exist,
pre
is NULL.
old: *mut yyjson_mut_val
The removed value if the operation is set
, replace
or remove
. It can
be used to restore the original state of the document if needed.
Trait Implementations§
Source§impl Clone for yyjson_ptr_ctx
impl Clone for yyjson_ptr_ctx
Source§fn clone(&self) -> yyjson_ptr_ctx
fn clone(&self) -> yyjson_ptr_ctx
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more