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

 
o_o:

1.12

set step 100 in ArrayResize

Do I need to update sources in Codebase?

 
Delta.800:

Dear specialists! Please help me to understand the library. ( I am not good at object-oriented programming yet, so I can't understand the code of the library itself and the article dedicated to the BTC-E exchange. that's why I ask for a simple example as in the post ).

I need to parse two public api of WEX.NZ exchange.

https://wex.nz/api/3/info

from here, I need to get all available pairs (btc_usd, btc_rur, ...) in an array (just pair names, without parameters, I can get parameters by known names...).


https://wex.nz/api/3/depth/btc_usd


and from here get the price and value of orders in two arrays (asks and bids).

I would be very grateful for your help!!! Thanks in advance!


show your code where you left off, what exactly is failing?
 
Rashid Umarov:

Do I need to update the sources in Codebase?

have been there for a long time
 

Good job, kudos!

However... If you get broken data for deserialisation (the number of opening quotes or brackets is not equal to the number of closing quotes or brackets), the program crashes with a message about array overrun. And this is very bad, such moments must be taken into account when working with arrays, at least if there is no check for correctness of input data.

 
Andrey Dik:

Good job, kudos!

However... If you get broken data for deserialisation (the number of opening quotes or brackets is not equal to the number of closing quotes or brackets), the program crashes with a message about array overrun. And this is very bad, such moments must be taken into account when working with arrays, at least if there is no check on the correctness of input data.

Please demonstrate the specific data
 
o_o:


show your code where you left off, what exactly you are failing at

In general, I can't even figure out how to get the names of all pairs from the first link :-(

---

I get access to the parameters of a pair from the first link in the following way:

CJAVal dataM;
dataM.Deserialize(ttt);  
... 
Print(dataM["pairs"]["btc_usd"]["fee"].ToDbl());

where ttt is the string obtained from the web request.

From the second link, I have solved the problem, I get access as follows:

Print(dataM["btc_usd"]["asks"].m_e[1][0].ToDbl());
where
m_e[X][Y]

X- order number (starting from zero)

Y- 0- is the price, 1- is the value .

 
Delta.800:

Anyway, I can't even figure out how to get the names of all the pairs from the first link :-(

---

I get access to the parameters of a pair from the first link in this way:

where ttt is the string obtained from the web request.

From the second link, I have solved the problem, I get access as follows:

where

X- order number (starting from zero)

Y- 0- is the price, 1- is the value .

and ok.

If it solves your problem now, use this solution.

If it is not enough, you will come up with something better.

 
o_o:

Okay.

If it solves your problem now, use it.

If it's not enough, you'll come up with something better.

No, no, no. You misunderstood a little bit...

I've solved everything except one! I need to get all the names of the pairs! I understand how to get the known ones, but how to get the unknown ones?

 
Yeah, I probably didn't understand what your problem was, by the lines you showed you were able to get everything.
 
o_o:
Demonstrate specific data

  //---
  in = "{\"asdasdasd\":{\"sdfs\":0.02189746,\"dfgdf\":0.01925917}}}}";
  out = "";
  b = js.Deserialize (in);
  js.Serialize (out);
  Print (out);
  
  //---
  in = "{\"asdasdasd\":{\"sdfs\":0.02189746,\"dfgdf\":0.01925917}}}";
  out = "";
  b = js.Deserialize (in);
  js.Serialize (out);
  Print (out);
  
  //---
  in = "{\"asdasdasd\":{\"sdfs\":0.02189746,\"dfgdf\":0.01925917}}";
  out = "";
  b = js.Deserialize (in);
  js.Serialize (out);
  Print (out);
  
  //---
  in = "{\"asdasdasd\":{\"sdfs\":0.02189746,\"dfgdf\":0.01925917}";
  out = "";
  b = js.Deserialize (in);
  js.Serialize (out);
  Print (out);
  
  //---
  in = "{\"asdasdasd\":{\"sdfs\":0.02189746,\"dfgdf\":0.01925917";
  out = "";
  b = js.Deserialize (in);
  js.Serialize (out);
  Print (out);


2018.02.21 14:03:39.861 jason_test(EURUSD,W1) {"asdasdasd":{"sdfs":0.02189746, "dfgdf":0.01925917}}
2018.02.21 14:03:39.861 jason_test (EURUSD,W1) {"asdasdasdasd":{"sdfs":0.02189746, "dfgdf":0.01925917}}
2018.02.21 14:03:39.861 jason_test (EURUSD,W1) {"asdasdasd":{"sdfs":0.02189746, "dfgdf":0.01925917}}
2018.02.21 14:03:39.861 jason_test (EURUSD,W1) {"asdasdasdasd":{"sdfs":0.02189746, "dfgdf":0.01925917}}
2018.02.21 14:03:39.862 jason_test (EURUSD,W1) array out of range in 'json.mqh' (597,19)