//+------------------------------------------------------------------+ //| JsomMinify.mqh | //| Copyright 2026, Niquel Mendoza. | //| https://www.mql5.com | //+------------------------------------------------------------------+ #property copyright "Copyright 2026, Niquel Mendoza." #property link "https://www.mql5.com" #property strict #ifndef JSONPARSERBYLEO_SRC_JSONUTILS_JSONMINIFY_MQH #define JSONPARSERBYLEO_SRC_JSONUTILS_JSONMINIFY_MQH //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #include "..\\JsonCore\\JsonDefines.mqh" //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ namespace TSN { //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ #define JSONMINIFY_PADD_SIZE (2) //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ class CJsonUtils { public: CJsonUtils(void) {} ~CJsonUtils(void) {} //--- // in = array de entrada // read_i = indice de lecutra // len = tamaño de lecutra // out = buffer de salida // oi = indice de escritura.. static void Minify(const uchar& in[], int read_i, int len, uchar& out[], int& oi); // fpos = len + read_i (añade el padding como tal solo eso...) static void MinifyCorrects(uchar& in[], int fpos); }; //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ static void CJsonUtils::MinifyCorrects(uchar &in[], int fpos) { //--- const int req = fpos + JSONMINIFY_PADD_SIZE; if(req >= ArraySize(in)) ArrayResize(in, req); //--- in[fpos] = '"'; in[fpos + 1] = '"'; } //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ // len = ", len+1 = " (len minimo es de 2.. siemrpe..) static void CJsonUtils::Minify(const uchar &in[], int read_i, int len, uchar &out[], int& oi) { //--- len += read_i; read_i--; uchar c; //--- while(true) { //--- Saltamos los ws while((c = in[++read_i]) < 33) {} //--- Siempre lo ponemos out[oi++] = c; //--- Verificamos si es string if(c != '"') continue; //--- while((c = in[++read_i]) != '"') { out[oi++] = c; if(c == '\\') out[oi++] = in[++read_i]; } //--- out[oi++] = c; //--- solo comprobamos al final de un string if(read_i >= len) break; } //--- read_i solo se adeltna 1 dado que pisa dos caracters "" digmoas si len es 19 enotnces elera 19 y 20 // read_i qeudara en 20-19 = 1 char (en si 2 por eso el +1) oi -= (read_i - len) + 1; // Sobrante } } //--- #endif // JSONPARSERBYLEO_SRC_JSONUTILS_JSONMINIFY_MQH