Fan sayfamıza katılın
Öyleyse bir link gönderin -
başkalarının da faydalanmasını sağlayın
JSON Serialization and Deserialization (native MQL) - MetaTrader 5 için kütüphane
- Görüntülemeler:
- 31712
- Derecelendirme:
- Yayınlandı:
- 2015.10.12 14:47
- Güncellendi:
- 2018.01.08 15:27
- Bu koda dayalı bir robota veya göstergeye mi ihtiyacınız var? Freelance üzerinden sipariş edin Freelance'e git
Serialization and deserialization of JSON protocol. The code is ported from a high-speed С++ library.
string in, out; CJAVal js(NULL, jtUNDEF); bool b; //--- Print("JASon Example Deserialization:"); in="{\"a\":[1,2]}"; out=""; // example of input data b=js.Deserialize(in); // deserialized js.Serialize(out); // serialized again Print(in+" -> "+out); // output for comparison //--- Print("JASon Example Serialization:"); js["Test"]=1.4; // input data example out=""; js.Serialize(out); // serialized Print(out); // output
Practical example: authorization on a website and parsing the response
CJAVal jv; jv["login"]="Login"; // login jv["password"]="Pass"; // password //--- serialize to string {"login":"Login","password":"Pass"} char data[]; ArrayResize(data, StringToCharArray(jv.Serialize(), data, 0, WHOLE_ARRAY)-1); //--- send data char res_data[]; string res_headers=NULL; int r=WebRequest("POST", "http://my.site.com/Authorize", "Content-Type: text/plain\r\n", 5000, data, res_data, res_headers); //--- assume the answer {"accessToken":"ABRAKADABRA","session_id":124521} //--- get AccessToken jv.Deserialize(res_data); string AccessToken=jv["accessToken"].ToStr();
You can show your gratitude by sending examples of implementing MQL for working with web resources. Share you experience with JSON in MQL.
MetaQuotes Ltd tarafından Rusçadan çevrilmiştir.
Orijinal kod: https://www.mql5.com/ru/code/13663
The ForecastOscilator indicator with the timeframe selection option available in the input parameters.
Flat_HTFThe Flat indicator with the timeframe selection option available in the input parameters.
The FX5_SelfAdjustingRSI indicator with the timeframe selection option available in the input parameters.
FX5_SelfAdjustingCCIThe CCI oscillator with the boundaries of the overbought/oversold areas in the form of Bollinger Bands.