JSON
JSON Support in ManapiHttp
JSON in C++
By default, C++ does not have built-in JSON support.
To address this, ManapiHttp provides a JSON implementation in the <manapihttp/json/ManapiJson.hpp> header file.
Warning
Currently, JSON parsing may be slow in some cases.
Initialization
There are two ways to create JSON objects:
- From text:
- Using C++ structures:
Types
ManapiHttp's JSON implementation supports all standard types, which can be accessed using several non-const methods.
Information
If you need to convert between types, you can use the following casting methods:
Warning
Integer Type
Constructor
Arithmetic Operations
String Type
Constructor
String Operations
Bigint Type
Constructor
Bigint Operations
Decimal Type
Constructor
Decimal Operations
Array Type
Constructor
Array Operations
Object Type
Constructor
Object Operations
Serializing JSON
Compact Output (without whitespace)
Formatted Output (with indentation)
Output:
Incremental Parsing
The manapi::json_builder class allows incremental JSON parsing in chunks.
Why is this useful?
manapi::json_builder combined with manapi::json_mask is used by the HTTP layer to process chunked data.
This approach provides early error detection - if the body is large and contains an error in the middle, it will fail immediately without processing the entire input.