2026-06-18 09:58:55 -05:00 | | | //+------------------------------------------------------------------+
|
| | | //| 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()
|
| | | {
|
2026-06-18 10:47:08 -05:00 | | | //---
|
2026-06-24 18:59:32 -05:00 | | | string json = "{\"ae\":[[10,10],[20,20]],\"comida\":\"holaaaaaaaaaaaaaa\\\\a\\\\a\\\\a\",\"trapo\":10.05,\"a\":true,\"invalid\":-0.20}";
|
2026-06-18 10:47:08 -05:00 | | | //Print(json);
|
| | |
|
2026-06-18 09:58:55 -05:00 | | | //---
|
| | | TSN::CJsonParser parser;
|
2026-06-18 10:47:08 -05:00 | | | parser.Assing(json);
|
2026-07-20 10:27:49 -05:00 | | | parser.CorrectPadding();
|
2026-06-18 10:47:08 -05:00 | | | 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[];
|
2026-06-20 18:24:46 -05:00 | | | Print(ArrayCopy(tape_one, parser.m_cinta, 0, 0, parser.m_cinta_pos));
|
2026-06-18 10:47:08 -05:00 | | |
|
| | | //---
|
| | | Print("Parseando ASM");
|
2026-07-20 10:27:49 -05:00 | | | ArrayCopy(parser.m_raw, data);
|
2026-06-18 10:47:08 -05:00 | | | parser.CalcLen();
|
| | | //Print(CharArrayToString(parser.m_json));
|
| | |
|
| | | //---
|
2026-06-20 18:24:46 -05:00 | | | Print("ASM Exit: " , parser.ParseAssembly());
|
2026-06-18 10:47:08 -05:00 | | | Print(EnumToString(parser.LastErr()));
|
| | | int col, line;
|
| | | parser.GetLastErrorLocation(col, line);
|
| | | PrintFormat("Line: %d | Col %d", line, col);
|
2026-07-20 10:27:49 -05:00 | | | Print(CharArrayToString(parser.m_raw, 0, parser.m_pos));
|
2026-06-18 10:47:08 -05:00 | | |
|
| | | Print("JSON TAPE LUEGO DE PARSEAR ASM");
|
2026-06-18 09:58:55 -05:00 | | | parser.PrintCintaTypes(0, WHOLE_ARRAY);
|
| | | //---
|
2026-06-18 10:47:08 -05:00 | | | long tape_dos[];
|
2026-06-20 18:24:46 -05:00 | | | Print(ArrayCopy(tape_dos, parser.m_cinta, 0, 0, parser.m_cinta_pos));
|
2026-06-18 09:58:55 -05:00 | | |
|
| | | //---
|
2026-06-20 18:24:46 -05:00 | | | PrintFormat("Es igaul = %s", (ArraySize(tape_one) == ArraySize(tape_dos) ? "si" : "no"));
|
2026-06-18 09:58:55 -05:00 | | | }
|
| | | //+------------------------------------------------------------------+
|