//+------------------------------------------------------------------+ //| Test.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\\JsonNode.mqh" //+------------------------------------------------------------------+ //| Script program start function | //+------------------------------------------------------------------+ void OnStart() { //--- string json = "{\"ae\":[[10,10],[20,20],[]],\"comida\":\"\\ud83d\\ude00\",\"trapo\":10.05,\"a\":true,\"invalid\":\"幸せの☆お守り\",\"precios\":[10,20,30,40,50],\"va\":1" ",\"interpolado\":\"${{valor}}\"}"; //Print(json); //--- TSN::CJsonParser parser; parser.Assing(json); parser.CorrectPadding(); Print(parser.Parse()); parser.ErrorInfo(); parser.PrintCintaTypes(0, WHOLE_ARRAY); //--- TSN::CJsonNode root = parser.GetRoot(); //--- Print("Claves: "); string keys[]; root.GetKeys(keys); ArrayPrint(keys, _Digits, " | "); //--- Calentar para JIT (3 iter) for(int i = 0; i < 7; i++) { root["trapo"].ToDouble(0.00); } Print("Root is JIT: ", root.ObjectIsJit()); //--- //const string tres = root.AtObjKey(3); //Print("Tercera key: ", tres, " index: ", root.KeyToPosition(tres)); //--- Print("Trapo val: ", root["trapo"].ToDouble(0.00)); //--- TSN::CJsonNode fa = root["ae"].At(0); Print("Valor anidado: ", fa.At(0).ToInt(0)); // 10 //--- string precios[]; Print("Array precios: "); root["precios"].ToArray(precios); ArrayPrint(precios, _Digits, " | "); PrintFormat("Precio[0] = '%s'", root["precios"].At(0).ToString()); //--- Print("Root key el 0: ", root.AtObjKey(0)); Print("Root size: ", root.Size()); Print("Root is valid: ", root.IsValid()); Print("Root emoji: ", root["comida"].ToString()); Print("Root emoji no escape: ", root["comida"].ToStringNoEscape()); Print("Root invalid: ", root["invalid"].ToString()); Print("Has key comida: ", root.HasKey("comida")); Print("First value type obj: ", EnumToString(root.AtObj(0).GetType())); Print("Va value:", root["va"].ToInt(0)); //--- Print("Iteracion ----"); CJsonIteratorObj it = root.BeginObj(); while(it.IsValid()) { Print("Element of root: ", parser.GetRawAsStr(it.KeyIndex())); it.Next(); } } //+------------------------------------------------------------------+