Hi coders,
I am looking for a JSON parser library for my MQL5 project. I have read some data online through WebRequest which is JSON data. I need to read it from MQL5 code to get the value.
Thanks in advanced.
#JSON_Parser
#MQL5_Code
Something like this? https://www.mql5.com/en/code/13663

- www.mql5.com
Something like this? https://www.mql5.com/en/code/13663
Thank you so much 'Fernando Morales'. It's work well.
please how can i adapt the json library parser to deserialize and loop through this list
[ { "time": "2025-02-05T16:17:00", "support1": 1.25069, "resistance1": 1.2511999999999999, "support2": 0.0, "resistance2": 0.0, "pivot_low": 1.25069, "pivot_high": 1.25089, "effective_pivot": 1.25069, "Trend": true, "Tick_command": "Buy_now", "id": 648 }, { "time": "2025-02-05T16:06:00", "support1": 1.25149, "resistance1": 1.25173, "support2": 0.0, "resistance2": 0.0, "pivot_low": 1.2516, "pivot_high": 1.25203, "effective_pivot": 1.25203, "Trend": true, "Tick_command": "Sell_now", "id": 647 }, { "time": "2025-02-05T15:56:00", "support1": 1.25119, "resistance1": 1.25164, "support2": 0.0, "resistance2": 0.0, "pivot_low": 1.25119, "pivot_high": 1.25157, "effective_pivot": 1.25119, "Trend": true, "Tick_command": "Buy_now", "id": 646 } ]
Improperly formatted data edited by moderator. Please use the CODE button (Alt-S) when inserting code or data and format/style it properly.
in my experience working with the JAson library is that, It works best when a json result is in a simple format (wrapped in a single curly bracket), with no arrays and fancy objects just scalars.
In your case you might want to return a simple json format at once.
{ "time": "2025-02-05T16:17:00", "support1": 1.25069, "resistance1": 1.2511999999999999, "support2": 0.0, "resistance2": 0.0, "pivot_low": 1.25069, "pivot_high": 1.25089, "effective_pivot": 1.25069, "Trend": true, "Tick_command": "Buy_now", "id": 648 }

- www.mql5.com
Hi ,this applies to the data structure you shared , if the data structure changes you will have to re-adapt the code.
#include "jason_with_search.mqh"; int OnInit() { EventSetMillisecondTimer(44); return(INIT_SUCCEEDED); } void OnTimer(){ EventKillTimer(); //""receive"" the string if(FileIsExist("feed.txt")){ int f=FileOpen("feed.txt",FILE_READ|FILE_TXT|FILE_ANSI); if(f!=INVALID_HANDLE){ string feed=""; while(!FileIsEnding(f)){ feed+=FileReadString(f); } FileClose(f); CJAVal loader; loader.Clear(); loader.Deserialize(feed,CP_ACP); int total_items=ArraySize(loader.m_e); Print("loader items "+IntegerToString(total_items)); //loop to the items for(int i=0;i<total_items;i++){ //get time Print("Item("+IntegerToString(i)+") Time("+loader[i]["time"].ToStr()+")"); } }else{Print("Cannot open file");} }else{Print("Test file does not exist");} } void OnDeinit(const int reason) { } void OnTick() { }

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Hi coders,
I am looking for a JSON parser library for my MQL5 project. I have read some data online through WebRequest which is JSON data. I need to read it from MQL5 code to get the value.
Thanks in advanced.
#JSON_Parser
#MQL5_Code