After update MetaEditor to Version: 5.00 build 1498, compiling the code generates error bellow:
cannot implicitly convert type 'string' to 'bool'.
Line 53: void operator=(string a) { m_type=a?jtSTR:jtNULL; m_sv=a; m_iv=StringToInteger(m_sv); m_dv=StringToDouble(m_sv); m_bv=a!=NULL; }
It seems that m_type=a?jtSTR:jtNULL is not supported in this version.
After update MetaEditor to Version: 5.00 build 1498, compiling the code generates error bellow:
cannot implicitly convert type 'string' to 'bool'.
Line 53: void operator=(string a) { m_type=a?jtSTR:jtNULL; m_sv=a; m_iv=StringToInteger(m_sv); m_dv=StringToDouble(m_sv); m_bv=a!=NULL; }
It seems that m_type=a?jtSTR:jtNULL is not supported in this version.
Fixes:
Line 53: void operator=(string a) { m_type=a!=NULL?jtSTR:jtNULL; m_sv=a; m_iv=StringToInteger(m_sv); m_dv=StringToDouble(m_sv); m_bv=a!=NULL; }
Line 80: case jtSTR: m_sv=Unescape(a); m_type=m_sv!=NULL?jtSTR:jtNULL; m_iv=StringToInteger(m_sv); m_dv=StringToDouble(m_sv); m_bv=m_sv!=NULL; break;
The author has published an update which addresses this issue.
I have fixed this issue. But it will be good to see what the author did. How can I find it? Thanks.
Suppose:
How can I map this to MQL types after Deserialize?
Would anyone or the author answer if this is supposed to support nested JSON? That is a CJAVal instance contains a keys '2', and '3' which are another CJAVal instance. Code seems to run but when serialized the keys are blank.
Example, I am getting:
{"":{"sl":5270.98000000,"tp":5285.26000000,"order":2},"":{"sl":5274.80000000,"tp":5289.06000000,"order":3}}
But should be getting
{"2":{"sl":5270.98000000,"tp":5285.26000000,"order":2},"3":{"sl":5274.80000000,"tp":5289.06000000,"order":3}}
Would anyone or the author answer if this is supposed to support nested JSON? That is a CJAVal instance contains a keys '2', and '3' which are another CJAVal instance. Code seems to run but when serialized the keys are blank.
Example, I am getting:
But should be getting
https://www.mql5.com/ru/forum/63015
a few examples
string a[] = {"1", "2", "3"}; int b[] = {1, 2, 3}; CJAVal js; js["a"].Add(a[0]); js["a"].Add(a[1]); js["a"].Add(a[2]); js["b"].Add(b[0]); js["b"].Add(b[1]); js["b"].Add(b[2]); js["c"][0]=1.1; js["c"][1]=2.9; js["c"][2]=3.03; string t=js.Serialize(); Print(t); // {"a":["1","2","3"],"b":[1,2,3],"c":[1.10000000,2.90000000,3.03000000]} js.Clear(); js.Deserialize(t); Print(js["c"][2].ToStr()); // 3.03000000
array of arrays
JAval j1; j1.Add(1); JAval j2; j2.Add(2); j2.Add(3); JAval js; js["a"].Add(j1); js["a"].Add(j2); // { a: [ [1], [2,3] ]; }
- 2015.08.18
- www.mql5.com
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
JSON Serialization and Deserialization (native MQL):
Serialization and deserialization of JSON protocol. The code is ported from a high-speed С++ library.
Practical example: authorization on a website and parsing the response
Author: o_O