Libraries: JSON Serialization and Deserialization (native MQL) - page 6

 
Hi there, firstly thanks for this very powerful tool - is there by any chance some documentation available anywhere? or some more examples of usage? Warm regards
 

v 1.09

- added possibility to serialise double numbers with specified precision (default was 8 digits).
For this purpose, added accuracy parameter m_prec, which can be set either manually or when calling the constructor or Add function.

- fixed bug in MT4 due to different behaviour of ArrayCopy function from MT5 (WHOLE_ARRAY constant is different).

Files:
JAson.mqh  31 kb
 
o_o:

v 1.09

- added possibility to serialise double numbers with specified precision (default was 8 digits).
For this purpose, added accuracy parameter m_prec, which can be set either manually or when calling the constructor or Add function.

- fixed a bug in MT4 due to different behaviour of ArrayCopy function from MT5 (WHOLE_ARRAY constant is different).

Updated in all languages
 

calling ArraySize( js["json value"] ) from my code;

gives a compilation error

'operator[]' - variable expected


using mql 4


to solve the problem I added to JAson.mqh:

int size() { return ArraySize(m_e); }

to determine the array size


question: is there any way to determine the array size?

Maybe I haven't found it.


apparently you need to do it like this

ArraySize( js["json value"].m_e )


internal function size() is more convenient for me.

 

1.10

Added int Size() function to return the number of elements

example

n=js["object_name"].Size(); // количество элементов в объекте
n=js["array_name"].Size(); // количество элементов в массиве

// альтернатива
n=ArraySize(js["object_name"].m_e);
n=ArraySize(js["array_name"].m_e);

Files:
JAson.mqh  31 kb
 
o_o:

1.10

Added int Size() function to return the number of elements

example

n=js["object_name"].Size(); // количество элементов в объекте
n=js["array_name"].Size(); // количество элементов в массиве

// альтернатива
n=ArraySize(js["object_name"].m_e);
n=ArraySize(js["array_name"].m_e);


Great! nice work thanks for the code!

 

v 1.11

- fixed default value of m_prec parameter (to =8) taking into account behaviour of DoubleToString function

Если значение m_prec лежит в диапазоне от 0 до 16, то будет получено строковое представление числа с указанным количество знаков после запятой.
Если значение
m_prec лежит в диапазоне от -1 до -16, то будет получено строковое представление числа в научном формате с указанным количеством знаков после запятой.
Во всех остальных случаях строковое представление числа будет содержать 8 знаков после запятой.

Files:
JAson.mqh  31 kb
 

v 1.11

- The value of parameter m_prec is corrected (=8)in view of the description DoubleToString.

Wenn sich der Wert m_prec im Bereich von 0 bis 16 befindet,bekommt man die Zeilendarstellung der Zahl mit der angegebenen Zahl der Dezimalzeichen.
Wenn sich der Wert
m_prec im Bereich von -1 bis -16 befindet, bekommt man Zeilendarstellung der Zahl im wissenschaftlichen Format mit der angegebenen Anzahl der Dezimalzeichen nach dem Komma.
In allen anderen Faellen wird der Zeilenwert der Zahl 8 Dezimalzeichen nach dem Komma enthalten.


Files:
JAson.mqh  31 kb
 

Thank you!
Wonderful library.

 
o_o:

v1.08

Fixed parsing of array of arrays (e.g. { "a":[[1],[2]] } )


Alexey, how do you "parse" an array of arrays? I'm writing a library for telegram right now, the custom keyboard is a json object of an array of arrays of arrays of json objects