Nyx Node
Loading...
Searching...
No Matches
JSON serialization / deserialization
Collaboration diagram for JSON serialization / deserialization:

Topics

 JSON Null Object
 JSON Number Object
 JSON Boolean Object
 JSON String Object
 JSON Dict Object
 JSON List Object

Classes

struct  nyx_object_t
 Struct describing a JSON object. More...

Macros

#define NYX_OBJECT_MAGIC   UINT32_C(0x65656500)
 Magic number for identifying JSON objects.

Enumerations

enum  nyx_type_t {
  NYX_TYPE_NULL = NYX_OBJECT_MAGIC | 0 ,
  NYX_TYPE_BOOLEAN = NYX_OBJECT_MAGIC | 1 ,
  NYX_TYPE_NUMBER = NYX_OBJECT_MAGIC | 2 ,
  NYX_TYPE_STRING = NYX_OBJECT_MAGIC | 3 ,
  NYX_TYPE_DICT = NYX_OBJECT_MAGIC | 4 ,
  NYX_TYPE_LIST = NYX_OBJECT_MAGIC | 5
}
 JSON object types. More...

Functions

__NYX_NULLABLE__ nyx_object_tnyx_object_t::nyx_object_parse_buff (__NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
 Parses a JSON object from a string buffer.
__NYX_NULLABLE__ nyx_object_tnyx_object_t::nyx_object_parse (__NYX_NULLABLE__ STR_t string)
 Parses a JSON object from a C string.
__NYX_NULLABLE__ nyx_object_tnyx_object_t::nyx_object_ref (__NYX_NULLABLE__ void *object)
 Increments the reference counter of the provided JSON object.
__NYX_NULLABLE__ nyx_object_tnyx_object_t::nyx_object_unref (__NYX_NULLABLE__ void *object)
 Decrements the reference counter of the provided JSON object and frees it when it reaches zero.
nyx_type_t nyx_object_t::nyx_object_get_type (__NYX_NULLABLE__ const nyx_object_t *object)
 Gets the type of the provided JSON object.
bool nyx_object_t::nyx_object_notify (__NYX_NULLABLE__ const nyx_object_t *object)
 Notifies the provided Nyx / INDI object to the clients.
bool nyx_object_t::nyx_object_equal (__NYX_NULLABLE__ const nyx_object_t *object1, __NYX_NULLABLE__ const nyx_object_t *object2)
 Compares two JSON objects.
str_t nyx_object_t::nyx_object_to_string (__NYX_NULLABLE__ const nyx_object_t *object)
 Returns a string, with the special character escaping, representing the provided JSON object.
str_t nyx_object_t::nyx_object_to_cstring (__NYX_NULLABLE__ const nyx_object_t *object)
 Returns a C string, without special character escaping, representing the provided JSON object.

Detailed Description

JSON serialization / deserialization.


Class Documentation

◆ nyx_object_t

struct nyx_object_t

Struct describing a JSON object.

Public Member Functions

__NYX_NULLABLE__ nyx_object_tnyx_object_parse_buff (__NYX_ZEROABLE__ size_t size, __NYX_NULLABLE__ BUFF_t buff)
 Parses a JSON object from a string buffer.
__NYX_NULLABLE__ nyx_object_tnyx_object_parse (__NYX_NULLABLE__ STR_t string)
 Parses a JSON object from a C string.
__NYX_NULLABLE__ nyx_object_tnyx_object_ref (__NYX_NULLABLE__ void *object)
 Increments the reference counter of the provided JSON object.
__NYX_NULLABLE__ nyx_object_tnyx_object_unref (__NYX_NULLABLE__ void *object)
 Decrements the reference counter of the provided JSON object and frees it when it reaches zero.
nyx_type_t nyx_object_get_type (__NYX_NULLABLE__ const nyx_object_t *object)
 Gets the type of the provided JSON object.
bool nyx_object_notify (__NYX_NULLABLE__ const nyx_object_t *object)
 Notifies the provided Nyx / INDI object to the clients.
bool nyx_object_equal (__NYX_NULLABLE__ const nyx_object_t *object1, __NYX_NULLABLE__ const nyx_object_t *object2)
 Compares two JSON objects.
str_t nyx_object_to_string (__NYX_NULLABLE__ const nyx_object_t *object)
 Returns a string, with the special character escaping, representing the provided JSON object.
str_t nyx_object_to_cstring (__NYX_NULLABLE__ const nyx_object_t *object)
 Returns a C string, without special character escaping, representing the provided JSON object.

Enumeration Type Documentation

◆ nyx_type_t

enum nyx_type_t

JSON object types.

Enumerator
NYX_TYPE_NULL 

Null object.

NYX_TYPE_BOOLEAN 

Boolean object.

NYX_TYPE_NUMBER 

Number object.

NYX_TYPE_STRING 

String object.

NYX_TYPE_DICT 

Dict object.

NYX_TYPE_LIST 

List object.

Definition at line 432 of file nyx_node.h.

Function Documentation

◆ nyx_object_parse_buff()

__NYX_NULLABLE__ nyx_object_t * nyx_object_parse_buff ( __NYX_ZEROABLE__ size_t size,
__NYX_NULLABLE__ BUFF_t buff )

Parses a JSON object from a string buffer.

Parameters
sizeString size.
buffString pointer.
Returns
The new JSON object.

◆ nyx_object_parse()

__NYX_NULLABLE__ nyx_object_t * nyx_object_parse ( __NYX_NULLABLE__ STR_t string)

Parses a JSON object from a C string.

Parameters
stringC string.
Returns
The new JSON object.

◆ nyx_object_ref()

__NYX_NULLABLE__ nyx_object_t * nyx_object_ref ( __NYX_NULLABLE__ void * object)

Increments the reference counter of the provided JSON object.

Parameters
objectJSON object.
Returns
The input JSON object of NULL.

◆ nyx_object_unref()

__NYX_NULLABLE__ nyx_object_t * nyx_object_unref ( __NYX_NULLABLE__ void * object)

Decrements the reference counter of the provided JSON object and frees it when it reaches zero.

Parameters
objectJSON object.
Returns
The input JSON object of NULL.

◆ nyx_object_get_type()

nyx_type_t nyx_object_get_type ( __NYX_NULLABLE__ const nyx_object_t * object)

Gets the type of the provided JSON object.

Parameters
objectJSON object.
Returns
The type.

◆ nyx_object_notify()

bool nyx_object_notify ( __NYX_NULLABLE__ const nyx_object_t * object)

Notifies the provided Nyx / INDI object to the clients.

Parameters
objectThe provided Nyx / INDI object.

◆ nyx_object_equal()

bool nyx_object_equal ( __NYX_NULLABLE__ const nyx_object_t * object1,
__NYX_NULLABLE__ const nyx_object_t * object2 )

Compares two JSON objects.

Parameters
object1First JSON object.
object2Second JSON object.
Returns
true if the objects are equal, false otherwise.

◆ nyx_object_to_string()

str_t nyx_object_to_string ( __NYX_NULLABLE__ const nyx_object_t * object)

Returns a string, with the special character escaping, representing the provided JSON object.

Parameters
objectJSON object.
Returns
A newly allocated string that represents the provided JSON object.
Note
Must be freed with nyx_memory_free.

◆ nyx_object_to_cstring()

str_t nyx_object_to_cstring ( __NYX_NULLABLE__ const nyx_object_t * object)

Returns a C string, without special character escaping, representing the provided JSON object.

Parameters
objectJSON object.
Returns
A newly allocated string that represents the provided JSON object.
Note
Must be freed with nyx_memory_free.