CJson

Struct CJson 

Source
pub struct CJson { /* private fields */ }
Expand description

Safe wrapper for cJSON pointer

Implementations§

Source§

impl CJson

Source

pub fn as_ptr(&self) -> *const cJSON

Get the raw pointer (does not transfer ownership)

Source

pub fn as_mut_ptr(&mut self) -> *mut cJSON

Get the mutable raw pointer (does not transfer ownership)

Source

pub fn into_raw(self) -> *mut cJSON

Consume the wrapper and return the raw pointer (transfers ownership)

Source

pub fn parse(json: &str) -> CJsonResult<Self>

Parse a JSON string

Source

pub fn parse_with_length(json: &str, length: usize) -> CJsonResult<Self>

Parse a JSON string with specified length

Source

pub fn parse_with_opts( json: &str, require_null_terminated: bool, ) -> CJsonResult<Self>

Parse a JSON string with options

Source

pub fn print(&self) -> CJsonResult<String>

Print JSON to a formatted string

Source

pub fn print_unformatted(&self) -> CJsonResult<String>

Print JSON to an unformatted string

Source

pub fn is_invalid(&self) -> bool

Check if the item is invalid

Source

pub fn is_false(&self) -> bool

Check if the item is false

Source

pub fn is_true(&self) -> bool

Check if the item is true

Source

pub fn is_bool(&self) -> bool

Check if the item is a boolean

Source

pub fn is_null(&self) -> bool

Check if the item is null

Source

pub fn is_number(&self) -> bool

Check if the item is a number

Source

pub fn is_string(&self) -> bool

Check if the item is a string

Source

pub fn is_array(&self) -> bool

Check if the item is an array

Source

pub fn is_object(&self) -> bool

Check if the item is an object

Source

pub fn is_raw(&self) -> bool

Check if the item is raw JSON

Source

pub fn get_string_value(&self) -> CJsonResult<String>

Get string value

Source

pub fn get_number_value(&self) -> CJsonResult<f64>

Get number value as f64

Source

pub fn get_int_value(&self) -> CJsonResult<i32>

Get number value as i32

Source

pub fn get_bool_value(&self) -> CJsonResult<bool>

Get boolean value

Source

pub fn get_array_size(&self) -> CJsonResult<usize>

Get array size

Source

pub fn get_array_item(&self, index: usize) -> CJsonResult<CJsonRef>

Get array item by index (borrowed reference)

Source

pub fn get_object_item(&self, key: &str) -> CJsonResult<CJsonRef>

Get object item by key (borrowed reference)

Source

pub fn get_object_item_case_sensitive(&self, key: &str) -> CJsonResult<CJsonRef>

Get object item by key (case sensitive, borrowed reference)

Source

pub fn has_object_item(&self, key: &str) -> bool

Check if object has item with given key

Source

pub fn create_null() -> CJsonResult<Self>

Create a null value

Source

pub fn create_true() -> CJsonResult<Self>

Create a true value

Source

pub fn create_false() -> CJsonResult<Self>

Create a false value

Source

pub fn create_bool(value: bool) -> CJsonResult<Self>

Create a boolean value

Source

pub fn create_number(value: f64) -> CJsonResult<Self>

Create a number value

Source

pub fn create_string(value: &str) -> CJsonResult<Self>

Create a string value

Source

pub fn create_array() -> CJsonResult<Self>

Create an array

Source

pub fn create_object() -> CJsonResult<Self>

Create an object

Source

pub fn create_int_array(values: &[i32]) -> CJsonResult<Self>

Create an integer array

Source

pub fn create_double_array(values: &[f64]) -> CJsonResult<Self>

Create a double array

Source

pub fn create_string_array(values: &[&str]) -> CJsonResult<Self>

Create a string array

Source

pub fn add_item_to_array(&mut self, item: CJson) -> CJsonResult<()>

Add item to array

Source

pub fn delete_item_from_array(&mut self, index: usize) -> CJsonResult<()>

Delete item from array by index

Source

pub fn detach_item_from_array(&mut self, index: usize) -> CJsonResult<CJson>

Detach item from array by index

Source

pub fn add_item_to_object(&mut self, key: &str, item: CJson) -> CJsonResult<()>

Add item to object

Source

pub fn add_null_to_object(&mut self, key: &str) -> CJsonResult<()>

Add null to object

Source

pub fn add_true_to_object(&mut self, key: &str) -> CJsonResult<()>

Add true to object

Source

pub fn add_false_to_object(&mut self, key: &str) -> CJsonResult<()>

Add false to object

Source

pub fn add_bool_to_object(&mut self, key: &str, value: bool) -> CJsonResult<()>

Add boolean to object

Source

pub fn add_number_to_object(&mut self, key: &str, value: f64) -> CJsonResult<()>

Add number to object

Source

pub fn add_string_to_object( &mut self, key: &str, value: &str, ) -> CJsonResult<()>

Add string to object

Source

pub fn delete_item_from_object(&mut self, key: &str) -> CJsonResult<()>

Delete item from object by key

Source

pub fn detach_item_from_object(&mut self, key: &str) -> CJsonResult<CJson>

Detach item from object by key

Source

pub fn duplicate(&self, recurse: bool) -> CJsonResult<Self>

Duplicate the JSON item

Source

pub fn compare(&self, other: &CJson, case_sensitive: bool) -> bool

Compare two JSON items

Trait Implementations§

Source§

impl Drop for CJson

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl Freeze for CJson

§

impl RefUnwindSafe for CJson

§

impl !Send for CJson

§

impl !Sync for CJson

§

impl Unpin for CJson

§

impl UnwindSafe for CJson

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.