High-Performance JSON

 

If you are integrating Large Language Models (LLMs), the standard  JAson.mqh   The library is a bottleneck. Its recursive architecture and excessive memory allocations (creating thousands of objects for a single payload) are unacceptable for production systems.

We rebuilt the JSON parser from scratch.

Introducing   fast_json

An iterative, production-ready, resource-free JSON library designed for speed and stability.

Key technical improvements:

  1. Tape Architecture with Zero Allocation : Uses a single contiguous memory buffer ( long[] ) instead of thousands of fragmented objects. Drastically reduces the pressure on the garbage collector.
  2. Iterative state machine : replaces recursion with an explicit stack, eliminating the risk of stack overflow even with deeply nested payloads.
  3. SWAR Scanning : Implements SIMD (SWAR) text scanning to process 8 bytes per CPU cycle.
  4. O(1) Introspection :   HasKey()  and   Size()  They are instantaneous, unlike the linear O(N) search found in legacy libraries.

Benchmark results (Intel i7-10750H)

Operation fast_json Legacy Library (Jason) Accelerate
To analyze 137 ms 1540 ms 11.2x
Serialize 264 ms 568 ms 2.1x
Total round trips 421 ms 2129 ms 5.0x

Availability

The library is open source and available immediately.

Repository:   https://forge.mql5.io/14134597/fast_json.git

Codebase: https://www.mql5.com/pt/code/68596

fast_json
fast_json
  • 14134597
  • forge.mql5.io
Uma biblioteca JSON projetada para uso massivo de LLMs e menor latência.