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

Modules

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

Data Structures

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

Macros

#define NYX_OBJECT_MAGIC   UINT32_C(0x65656565)
 Magic number for identifying JSON objects.
 
#define NYX_FLAGS_DISABLED   UINT64_C(0x0000000000000001)
 
#define NYX_FLAGS_BLOB_MASK   UINT64_C(0x00000001FFFFFFFC)
 
#define NYX_FLAGS_STREAM_MASK   UINT64_C(0xFFFFFFFE00000000)
 

Typedefs

typedef struct nyx_object_s nyx_object_t
 

Enumerations

enum  nyx_type_t {
  NYX_TYPE_NULL = 200 ,
  NYX_TYPE_BOOLEAN = 201 ,
  NYX_TYPE_NUMBER = 202 ,
  NYX_TYPE_STRING = 203 ,
  NYX_TYPE_DICT = 204 ,
  NYX_TYPE_LIST = 205
}
 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.
 
void nyx_object_t::nyx_object_free (__NYX_NULLABLE__ nyx_object_t *object)
 Frees memory of the provided JSON object.
 
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 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.

Macro Definition Documentation

◆ NYX_OBJECT_MAGIC

#define NYX_OBJECT_MAGIC   UINT32_C(0x65656565)

Magic number for identifying JSON objects.

Definition at line 401 of file nyx_node.h.

◆ NYX_FLAGS_DISABLED

#define NYX_FLAGS_DISABLED   UINT64_C(0x0000000000000001)

Definition at line 405 of file nyx_node.h.

◆ NYX_FLAGS_BLOB_MASK

#define NYX_FLAGS_BLOB_MASK   UINT64_C(0x00000001FFFFFFFC)

Definition at line 408 of file nyx_node.h.

◆ NYX_FLAGS_STREAM_MASK

#define NYX_FLAGS_STREAM_MASK   UINT64_C(0xFFFFFFFE00000000)

Definition at line 411 of file nyx_node.h.

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 420 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_free()

void nyx_object_free ( __NYX_NULLABLE__ nyx_object_t object)

Frees memory of the provided JSON object.

Parameters
objectJSON 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 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.

◆ 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.