C++ Json parser without dynamic memory allocation
When working with C/C++, memory management is often the most error-prone aspect. Dynamic memory allocation, in particular, is a frequent source of bugs. For instance, a function may allocate memory and return a pointer to the caller. The caller is then tasked with freeing the memory. If the caller neglects to do so, a memory leak occurs.
However, with the introduction of move semantics in C++11, returning a large object from a function is no longer costly, provided the object is moved instead of copied. This allows objects to be returned by value without the need for memory management concerns.
To put this concept of using move semantics to the test, I decided to write a JSON parser that does not rely on dynamic memory allocation. It utilizes standard library containers and move semantics to circumvent memory allocation.
- The code can be found here:
- git repo Please note: The parser is still under development and does not yet support all JSON features.