65 lines
2.2 KiB
MQL5
65 lines
2.2 KiB
MQL5
//+------------------------------------------------------------------+
| |
//| JsonAsm.mq5 |
| |
//| Copyright 2026, Niquel Mendoza. |
| |
//| https://www.mql5.com/ |
| |
//+------------------------------------------------------------------+
| |
#property copyright "Copyright 2026, Niquel Mendoza."
| |
#property link "https://www.mql5.com/"
| |
#property version "1.00"
| |
#property strict
| |
| |
//+------------------------------------------------------------------+
| |
//| |
| |
//+------------------------------------------------------------------+
| |
#include "..\\Src\\JsonNode.mqh"
| |
| |
//+------------------------------------------------------------------+
| |
//| Script program start function |
| |
//+------------------------------------------------------------------+
| |
void OnStart()
| |
{
| |
//---
| |
string json = "{\"ae\":[[10,10],[20,20]],\"comida\":\"holaaaaaaaaaaaaaa\\\\a\\\\a\\\\a\",\"trapo\":10.05,\"a\":true,\"invalid\":-0.20}";
| |
//Print(json);
| |
| |
//---
| |
TSN::CJsonParser parser;
| |
parser.Assing(json);
| |
parser.CorrectPadding();
| |
Print(parser.Parse());
| |
| |
| |
//---
| |
uchar data[];
| |
parser.ToJsonAsm(data);
| |
Print("JSON ASM CODE: ");
| |
Print(CharArrayToString(data));
| |
Print("JSON CINTA: ");
| |
parser.PrintCintaTypes(0, WHOLE_ARRAY);
| |
long tape_one[];
| |
Print(ArrayCopy(tape_one, parser.m_cinta, 0, 0, parser.m_cinta_pos));
| |
| |
//---
| |
Print("Parseando ASM");
| |
ArrayCopy(parser.m_raw, data);
| |
parser.CalcLen();
| |
//Print(CharArrayToString(parser.m_json));
| |
| |
//---
| |
Print("ASM Exit: " , parser.ParseAssembly());
| |
Print(EnumToString(parser.LastErr()));
| |
int col, line;
| |
parser.GetLastErrorLocation(col, line);
| |
PrintFormat("Line: %d | Col %d", line, col);
| |
Print(CharArrayToString(parser.m_raw, 0, parser.m_pos));
| |
| |
Print("JSON TAPE LUEGO DE PARSEAR ASM");
| |
parser.PrintCintaTypes(0, WHOLE_ARRAY);
| |
//---
| |
long tape_dos[];
| |
Print(ArrayCopy(tape_dos, parser.m_cinta, 0, 0, parser.m_cinta_pos));
| |
| |
//---
| |
PrintFormat("Es igaul = %s", (ArraySize(tape_one) == ArraySize(tape_dos) ? "si" : "no"));
| |
}
| |
//+------------------------------------------------------------------+
|