pub struct CJson { /* private fields */ }Expand description
Safe wrapper for cJSON pointer
Implementations§
Source§impl CJson
impl CJson
Sourcepub fn as_mut_ptr(&mut self) -> *mut cJSON
pub fn as_mut_ptr(&mut self) -> *mut cJSON
Get the mutable raw pointer (does not transfer ownership)
Sourcepub fn into_raw(self) -> *mut cJSON
pub fn into_raw(self) -> *mut cJSON
Consume the wrapper and return the raw pointer (transfers ownership)
Sourcepub fn parse(json: &str) -> CJsonResult<Self>
pub fn parse(json: &str) -> CJsonResult<Self>
Parse a JSON string
Sourcepub fn parse_with_length(json: &str, length: usize) -> CJsonResult<Self>
pub fn parse_with_length(json: &str, length: usize) -> CJsonResult<Self>
Parse a JSON string with specified length
Sourcepub fn parse_with_opts(
json: &str,
require_null_terminated: bool,
) -> CJsonResult<Self>
pub fn parse_with_opts( json: &str, require_null_terminated: bool, ) -> CJsonResult<Self>
Parse a JSON string with options
Sourcepub fn print(&self) -> CJsonResult<String>
pub fn print(&self) -> CJsonResult<String>
Print JSON to a formatted string
Sourcepub fn print_unformatted(&self) -> CJsonResult<String>
pub fn print_unformatted(&self) -> CJsonResult<String>
Print JSON to an unformatted string
Sourcepub fn is_invalid(&self) -> bool
pub fn is_invalid(&self) -> bool
Check if the item is invalid
Sourcepub fn get_string_value(&self) -> CJsonResult<String>
pub fn get_string_value(&self) -> CJsonResult<String>
Get string value
Sourcepub fn get_number_value(&self) -> CJsonResult<f64>
pub fn get_number_value(&self) -> CJsonResult<f64>
Get number value as f64
Sourcepub fn get_int_value(&self) -> CJsonResult<i32>
pub fn get_int_value(&self) -> CJsonResult<i32>
Get number value as i32
Sourcepub fn get_bool_value(&self) -> CJsonResult<bool>
pub fn get_bool_value(&self) -> CJsonResult<bool>
Get boolean value
Sourcepub fn get_array_size(&self) -> CJsonResult<usize>
pub fn get_array_size(&self) -> CJsonResult<usize>
Get array size
Sourcepub fn get_array_item(&self, index: usize) -> CJsonResult<CJsonRef>
pub fn get_array_item(&self, index: usize) -> CJsonResult<CJsonRef>
Get array item by index (borrowed reference)
Sourcepub fn get_object_item(&self, key: &str) -> CJsonResult<CJsonRef>
pub fn get_object_item(&self, key: &str) -> CJsonResult<CJsonRef>
Get object item by key (borrowed reference)
Sourcepub fn get_object_item_case_sensitive(&self, key: &str) -> CJsonResult<CJsonRef>
pub fn get_object_item_case_sensitive(&self, key: &str) -> CJsonResult<CJsonRef>
Get object item by key (case sensitive, borrowed reference)
Sourcepub fn has_object_item(&self, key: &str) -> bool
pub fn has_object_item(&self, key: &str) -> bool
Check if object has item with given key
Sourcepub fn create_null() -> CJsonResult<Self>
pub fn create_null() -> CJsonResult<Self>
Create a null value
Sourcepub fn create_true() -> CJsonResult<Self>
pub fn create_true() -> CJsonResult<Self>
Create a true value
Sourcepub fn create_false() -> CJsonResult<Self>
pub fn create_false() -> CJsonResult<Self>
Create a false value
Sourcepub fn create_bool(value: bool) -> CJsonResult<Self>
pub fn create_bool(value: bool) -> CJsonResult<Self>
Create a boolean value
Sourcepub fn create_number(value: f64) -> CJsonResult<Self>
pub fn create_number(value: f64) -> CJsonResult<Self>
Create a number value
Sourcepub fn create_string(value: &str) -> CJsonResult<Self>
pub fn create_string(value: &str) -> CJsonResult<Self>
Create a string value
Sourcepub fn create_array() -> CJsonResult<Self>
pub fn create_array() -> CJsonResult<Self>
Create an array
Sourcepub fn create_object() -> CJsonResult<Self>
pub fn create_object() -> CJsonResult<Self>
Create an object
Sourcepub fn create_int_array(values: &[i32]) -> CJsonResult<Self>
pub fn create_int_array(values: &[i32]) -> CJsonResult<Self>
Create an integer array
Sourcepub fn create_double_array(values: &[f64]) -> CJsonResult<Self>
pub fn create_double_array(values: &[f64]) -> CJsonResult<Self>
Create a double array
Sourcepub fn create_string_array(values: &[&str]) -> CJsonResult<Self>
pub fn create_string_array(values: &[&str]) -> CJsonResult<Self>
Create a string array
Sourcepub fn add_item_to_array(&mut self, item: CJson) -> CJsonResult<()>
pub fn add_item_to_array(&mut self, item: CJson) -> CJsonResult<()>
Add item to array
Sourcepub fn delete_item_from_array(&mut self, index: usize) -> CJsonResult<()>
pub fn delete_item_from_array(&mut self, index: usize) -> CJsonResult<()>
Delete item from array by index
Sourcepub fn detach_item_from_array(&mut self, index: usize) -> CJsonResult<CJson>
pub fn detach_item_from_array(&mut self, index: usize) -> CJsonResult<CJson>
Detach item from array by index
Sourcepub fn add_item_to_object(&mut self, key: &str, item: CJson) -> CJsonResult<()>
pub fn add_item_to_object(&mut self, key: &str, item: CJson) -> CJsonResult<()>
Add item to object
Sourcepub fn add_null_to_object(&mut self, key: &str) -> CJsonResult<()>
pub fn add_null_to_object(&mut self, key: &str) -> CJsonResult<()>
Add null to object
Sourcepub fn add_true_to_object(&mut self, key: &str) -> CJsonResult<()>
pub fn add_true_to_object(&mut self, key: &str) -> CJsonResult<()>
Add true to object
Sourcepub fn add_false_to_object(&mut self, key: &str) -> CJsonResult<()>
pub fn add_false_to_object(&mut self, key: &str) -> CJsonResult<()>
Add false to object
Sourcepub fn add_bool_to_object(&mut self, key: &str, value: bool) -> CJsonResult<()>
pub fn add_bool_to_object(&mut self, key: &str, value: bool) -> CJsonResult<()>
Add boolean to object
Sourcepub fn add_number_to_object(&mut self, key: &str, value: f64) -> CJsonResult<()>
pub fn add_number_to_object(&mut self, key: &str, value: f64) -> CJsonResult<()>
Add number to object
Sourcepub fn add_string_to_object(
&mut self,
key: &str,
value: &str,
) -> CJsonResult<()>
pub fn add_string_to_object( &mut self, key: &str, value: &str, ) -> CJsonResult<()>
Add string to object
Sourcepub fn delete_item_from_object(&mut self, key: &str) -> CJsonResult<()>
pub fn delete_item_from_object(&mut self, key: &str) -> CJsonResult<()>
Delete item from object by key
Sourcepub fn detach_item_from_object(&mut self, key: &str) -> CJsonResult<CJson>
pub fn detach_item_from_object(&mut self, key: &str) -> CJsonResult<CJson>
Detach item from object by key
Sourcepub fn duplicate(&self, recurse: bool) -> CJsonResult<Self>
pub fn duplicate(&self, recurse: bool) -> CJsonResult<Self>
Duplicate the JSON item