Libraries: JSON Parser - page 4

 

Since the newest MT4 build (Version 4 Build 1212, 10 Sep 2019) the json.mqh does not compile any more.

The compiler complains about a protected class member not being accessible.

I fixed it here.

Files:
json.mqh  49 kb
 
winloosewin:

Since the newest MT4 build (Version 4 Build 1212, 10 Sep 2019) the json.mqh does not compile any more.

The compiler complains about a protected class member not being accessible.

I fixed it here.

Im seeing that you fix error "protected class member not being accessible" but show another error : "   'isValid' - function not defined json.mqh 649 46 "


Know how to fix it?

 
franconalinares:
Im seeing that you fix error "protected class member not being accessible" but show another error : "   'isValid' - function not defined json.mqh 649 46 "


Know how to fix it?

It seems that you use the original hash.mqh file from ydrol.

The error should be fixed if you use mine in the attachment.

Some time ago I added a function isValid() in hash.mqh that does exactly the same as the original hasNext() from ydrol.

In my opinion the name isValid() describes the behaviour of the function better.

Files:
hash.mqh  25 kb
 

I got a new problem.

When i run the EA, got a problem on 516 line of json.mqh you provided, always fail getValue(key) function

When compile the json.mqh and hash.mqh got many errores 581 in hash and 1739 on json.mqh

Someone got those problems.

 

Problem solved, was my mistake.


Thanks,

 

There is a subtle bug in the parsing of negative integers, where the preceding '-' is parsed as a digit, resulting in wrong values. This might already have been fixed in a newer version, but the link to the newest version in the library description (http://www.lordy.co.nf/mql4/) is broken.

A quick way to fix this is to change json.mqh line 670 from

l = l * 10 + ( _in[i] - '0' );

to

if (_in[i] != '-' && _in[i] != "+") {
        l = l * 10 + ( _in[i] - '0' );
}

I apologize if this has already been discussed.

 

Thank you winloosewin.

you are my hero.

 
zboo:

Thank you winloosewin.

you are my hero.

Thank you zboo.

@trader-aether: You refer to an old version of json.mqh . I fixed the error in my post from 2018.07.10 16:40.

The only case when there is still an error in my version is if after a + or - sign at the beginning there is another + or -,

e.g. --3 or -3+5 . I have an updated version with this bug fixed.

But in case of a malformed floating point number there is still a bug, e.g. when parsing 1.3.4E5E7 . This bug is NOT fixed yet.

I have an updated version with the integer bug fixed. I also repeat the hash.mqh file here.

trader-aether
trader-aether
  • www.mql5.com
Trader's profile
Files:
json.mqh  49 kb
hash.mqh  25 kb
 

Now I have also fixed the bug that occurs when there are malformed floating point numbers.

Additionally, I have fixed some bugs that occure when there is an unexpected end of the JSON file.

Files:
json.mqh  51 kb
 
winloosewin:

Now I have also fixed the bug that occurs when there are malformed floating point numbers.

Additionally, I have fixed some bugs that occure when there is an unexpected end of the JSON file.

Thank you so much! You are my hero <3