A high-performance, C++98-compatible JSON parser with colorized output, comprehensive error handling, and memory-safe design.
Built for reliability, performance, and ease of use in C++98 environments
Works seamlessly with legacy systems and older compilers. No modern C++ features required.
Beautiful ANSI color-coded JSON visualization with syntax highlighting for better readability.
Comprehensive error handling with detailed messages including line and column information.
Custom AutoPointer implementation prevents memory leaks and ensures safe resource management.
Single-pass parsing with minimal memory allocation for maximum efficiency.
Formatted JSON output with proper indentation and structure visualization.
Recursive descent parser with polymorphic value hierarchy
TrpJSON Parser
├── Core Components
│ ├── TrpJsonLexer - Tokenization and lexical analysis
│ └── TrpJsonParser - Recursive descent parser
├── Value Types
│ ├── ITrpJsonValue - Base interface for all JSON values
│ ├── TrpJsonObject - JSON objects (key-value pairs)
│ ├── TrpJsonArray - JSON arrays (ordered lists)
│ ├── TrpJsonString - JSON strings
│ ├── TrpJsonNumber - JSON numbers (integers and floats)
│ ├── TrpJsonBool - JSON booleans
│ └── TrpJsonNull - JSON null values
└── Utilities
├── AutoPointer - Memory management
└── AstToString - Colorized serialization
See the parser in action with colorized output
{
"non": false,
"routes": [
{
"autoindex": false,
"index": "index.html",
"path": "/",
"root": "/var/www/html"
},
{
"methods": ["GET", "POST"],
"path": "/api",
"proxy_pass": "http://127.0.0.1:5000"
},
{
"cache_control": "max-age=86400",
"path": "/static",
"root": "/var/www/static"
}
],
"security": {
"cors": {
"allowed_methods": ["GET", "POST", "PUT", "DELETE"],
"allowed_origins": ["*"],
"enabled": true
},
"rate_limit": {
"ban_time_minutes": 15,
"requests_per_minute": 60
}
},
"server": {
"host": "0.0.0.0",
"logging": {
"access_log": "/var/log/webserver/access.log",
"error_log": "/var/log/webserver/error.log",
"log_level": "info"
},
"port": 8080,
"ssl": {
"certificate": "/etc/ssl/certs/server.crt",
"enabled": true,
"key": "/etc/ssl/private/server.key"
}
},
"timeouts": {
"client_body_timeout": 60,
"client_header_timeout": 30,
"keepalive_timeout": 65
}
}
{
"non": false,
"routes": [
{
"autoindex": false,
"index": "index.html",
"path": "/",
"root": "/var/www/html"
},
{
"methods": [
"GET",
"POST"
],
"path": "/api",
"proxy_pass": "http://127.0.0.1:5000"
},
{
"cache_control": "max-age=86400",
"path": "/static",
"root": "/var/www/static"
}
],
"security": {
"cors": {
"allowed_methods": [
"GET",
"POST",
"PUT",
"DELETE"
],
"allowed_origins": [
"*"
],
"enabled": true
},
"rate_limit": {
"ban_time_minutes": 15,
"requests_per_minute": 60
}
},
"server": {
"host": "0.0.0.0",
"logging": {
"access_log": "/var/log/webserver/access.log",
"error_log": "/var/log/webserver/error.log",
"log_level": "info"
},
"port": 8080,
"ssl": {
"certificate": "/etc/ssl/certs/server.crt",
"enabled": true,
"key": "/etc/ssl/private/server.key"
}
},
"timeouts": {
"client_body_timeout": 60,
"client_header_timeout": 30,
"keepalive_timeout": 65
}
}
Tested on Intel i7-10700K, 32GB RAM, GCC 9.4.0, Ubuntu 20.04
Perfect for configuration files, API processing, and data pipelines
Parse complex application configuration with nested structures
Handle multi-level configuration files with database settings, feature flags, and environment-specific parameters.
{
"database": {
"pools": [
{"name": "read", "size": 10},
{"name": "write", "size": 5}
]
},
"logging": {"level": "info"}
}
Process REST API responses with proper error detection
Handle API responses with pagination, user data, and complex nested objects efficiently.
{
"data": {
"users": [
{"id": 1, "active": true},
{"id": 2, "active": false}
],
"pagination": {"total": 150}
}
}
Process large JSON datasets in streaming applications
Efficiently process large datasets with minimal memory usage and high throughput.
// Process each record efficiently
TrpJsonParser parser("dataset.json");
auto root = parser.parse();
for (size_t i = 0; i < records->size(); ++i) {
processRecord(records->at(i));
}
Optimized for speed and memory efficiency
Get up and running in seconds
# Clone the repository
git clone https://github.com/MliliGenes/TrpJSON.git
cd TrpJSON
# Build using make
make
# Or build manually
g++ -Wall -Wextra -std=c++98 -Iinclude \
-o TrpJSON main.cpp src/**/*.cpp
#include "TrpJsonParser.hpp"
int main() {
TrpJsonParser parser("config.json");
auto root = parser.parse();
if (root.get() != NULL) {
std::cout << astValueToString(root.get());
}
return 0;
}