- Data structures designed for efficiency and memory control.
- Linked lists are used for JSON arrays and objects to preserve order.
- Memory is managed through a static pool to avoid
mallocoverhead.
json_token: Enum for JSON value types (J_NULL,J_BOOLEAN,J_NUMBER,J_STRING,J_ARRAY,J_OBJECT).json_error: Enum for detailed JSON parsing and validation error codes.reference: A pointer to a slice of the original JSON string (ptr,len). Avoids allocations for primitive types.json_value: Represents any JSON value. Contains atypefield and aunionfor the specific value.json_object: Represents a key-value pair, where the key is areferenceand the value is ajson_value.json_array_node: A node in a linked list for array elements.json_object_node: A node in a linked list for object members.
- Static Pool (Default): A fixed-size pool of nodes is used for fast, "alloc-free" parsing.
- Predictable memory usage.
- Reduced heap fragmentation.
- Faster parsing.
- Dynamic Allocation (Optional): If
USE_ALLOCis defined,callocis used for node allocation.
- Primitives:
json_valueuses areferenceto point to the original string, avoiding data copies. - Arrays/Objects:
json_valuepoints to a linked list of nodes (json_array_nodeorjson_object_node). - O(1) Insertion: A
lastpointer in thejson_valuefor arrays and objects allows for constant-time element insertion at the end of the list.