Watch how to download trading robots for free
Find us on Twitter!
Join our fan page
Interesting script?
So post a link to it -
let others appraise it
You liked the script? Try it in the MetaTrader 5 terminal
Libraries

JsonParserByLeo - library for MetaTrader 5

Niquel Mendoza
Niquel Mendoza
Creator of the TSN ecosystem (Trade Systems Nique) for MQL5.
Views:
46
Published:
\MQL5\Include\ \MQL5\Scripts\
FastTest.mq5 (3.2 KB) view
MQL5 Freelance Need a robot or indicator based on this code? Order it on Freelance Go to Freelance

JsonParserByLeo is a JSON library for MQL5 built around a flat "tape" architecture. The whole document is parsed in a single iterative pass (strictly O(n), no recursion, no helper calls in the hot path) into one contiguous ulong[] array. Keys and strings are stored lazily as offset + length and are unescaped only when you read them.


Main features

  • Tape-based zero-allocation parsing, with strict validation of numbers, literals, strings and grammar order.
  • Safe number handling: full 64-bit unsigned support, and values that cannot be represented exactly are kept as strings, so no digits are lost.
  • Just-in-time perfect-hash key lookup: objects that are accessed often are promoted from linear scan to O(1) lookup automatically.
  • CJsonNode: lightweight handle (copying is free) with typed readers (ToString, ToInt, ToDouble, ToBool), iterators for objects and arrays, and access by key, index or pointer.
  • Mutable DOM (CDomNodeBase): add or remove keys, change a value type in place, Python-style array slicing, and serialize back to JSON.
  • Typed struct mapping: GetAs<T>() fills your own struct from a node or DOM node, and Load<T>() dumps a struct into the DOM.
  • SAX streaming parser: feeds the parser in fixed-size chunks and fires callbacks, so the whole document never has to be in memory.
  • JSON Builder, JSON minify, and JSON Pointer (RFC 6901) lookups.
  • JSONPath-like query VM: a small register-based virtual machine that filters and traverses a DOM tree.
  • Compiled tape cache (.jsontc): saves the tape and the built hash tables, so a later reload skips parsing.

Test

test



Basic usage

  1. Include the library header.
  2. Create a CJsonParser and call Assing() with your JSON text.
  3. Call CorrectPadding() and Parse().
  4. Get the root with GetRoot() and read values, for example root["price"].ToDouble(0.0).

The attached example script shows parsing, iteration, the DOM API, struct mapping and JSON Pointer in action.


Notes

  • The library is a single header file generated from the full modular project.
  • No DLL is required: this version is pure MQL5.
  • The full modular source, documentation, unit tests and benchmarks are available in the author's repository on MQL5 Algo Forge: https://forge.mql5.io/nique_372/JsonParserByLeo

License

Niquel & Leo NL-NC (bundled component TsnTables: MIT). Full notices and the list of bundled components are in the header of the source file.

Asia Session Range and Liquidity Sweep Zones (BSL/SSL) with Live HUD Asia Session Range and Liquidity Sweep Zones (BSL/SSL) with Live HUD

Plots daily Asia Session High/Low range boxes, extends session liquidity levels through London and New York sessions, and marks non-repainting closed-bar liquidity sweeps (BSL/SSL) with a live HUD.

Prop Firm Risk Headroom Monitor Prop Firm Risk Headroom Monitor

Account-wide MT5 prop firm risk monitor that tracks daily and maximum loss headroom, current stop-loss exposure, projected equity and remaining risk capacity.

Accelerator Oscillator (AC) Accelerator Oscillator (AC)

The Acceleration/Deceleration Indicator (AC) measures acceleration and deceleration of the current driving force.

MACD Signals MACD Signals

Indicator edition for new platform.