You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
The library is very useful. But I encountered that when serialising values of double type there is a strong loss of precision.
Example:
double minutes_open[] = {0.95347, 0.95317, 0.95324}
for (int i=0; i<ArraySize(minutes_open); ++i) jv["minutes_open"].Add(minutes_open[i]);
After serialisation I get:
"minutes_open":[9.53e-01,9.53e-01,9.53e-01]
I.e. the last 2 significant characters are simply lost and all values in the array become simply equal to each other. As a result, all the calculations based on this data go in vain....
In the end I got round it by converting array values into string.
Hi there!
Documentation of JAson library is not full at this site. I wrote documentation with more details and added unit tests: https://github.com/vivazzi/JAson. It may be useful for someone.
Add i created issue that has description of bug of using inner Json (CJAVal object): https://github.com/vivazzi/JAson/issues/1.
CJAVal object is not correctly assigned to another CJAVal object as object:
As workaround, you need use Set() method:
If anyone can help, then many MQL-developers will be grateful as this bug has been around for many years.
Hi everyone!!!
The JAson documentation is not complete on this site, so I wrote a more detailed documentation https://github.com/vivazzi/JAson/ and added unit tests: maybe someone will find it useful.
And I described the problem of using a nested Json (CJAVal object): https://github.com/vivazzi/JAson/issues/1.
CJAVal object is not correctly saved if you use "=" sign (empty key is saved):
Yes, in the tests attached on the library page on this site, you can find that you need to use the Set() method:
But if someone can fix the library so that it is possible to save nested Json structures via the "=" sign, it would help a lot of people. Since I've noticed that some people think the library has errors when they try to assign a nested CJAVal in the usual way via "=".
I hope this is even possible within the MQL language. I've tried to correct it myself, but I don't have a deep knowledge of the MQL language, and so far it hasn't worked to do assignment via "=".
Hi there!
Documentation of JAson library is not full at this site. I wrote documentation with more details and added unit tests: https://github.com/vivazzi/JAson. It may be useful for someone.
Add i created issue that has description of bug of using inner Json (CJAVal object): https://github.com/vivazzi/JAson/issues/1.
CJAVal object is not correctly assigned to another CJAVal object as object:
As workaround, you need use Set() method:
If anyone can help, then many MQL-developers will be grateful as this bug has been around for many years.
The problem is with the Copy method.
The key gets overwritten with the subobject's key in your example the "b" gets overwritten with the "nested_data"'s key which is empty.
I used this simple solution, not fully tested:
Thank you, Laszlo Tormasi - your fix works and all tests have passed!
I updated JAson with your fixes: https://github.com/vivazzi/JAson
The problem of assigning nested Json structures via the "=" sign was solved by Laszlo Tormasi in the comment https://www.mql5.com/en/forum/65320/page3#comment_21453129.
JAson version with editsat https://github.com/vivazzi/JAson.
Thanks to everyone who tried to understand the problem and help!
Fixed an error ("array out of range") that occurred with negative array indices. Now the [] operator returns NULL.
Processing looks like this.
Also, I added the ToIntI method for convenience. Since ToInt returns long.
I don't understand how to read the nested json.
Here is a string like this:
string str= { "key1": [ { "key2": [ { "key3": "val)" }, {}, {} ] } ] }How do I read it and access the elements?
No matter how I try, it doesn't work.I don't understand how to read the nested json.
Here is a string like this:
How do I read it and access the elements?
No matter how many times I try, I can't get it.string str; CJAVal data; str= "{" " \"key1\": [" " {" " \"key2\": [" " {" " \"key3\": \"val)\"" " }," " {}," " {}" " ]" " }" " ]" "}"; data.Deserialize(str); Print(data["key1"][0]["key2"][0]["key3"].ToStr());If you don't understand the structure of your json string or something goes wrong, do the following:
To easily understand the structure of a json string use this site: https: //jsoneditoronline.org/.