How to Retrive Array Data from WebRequest Response

 
char     post[], result[];

string   str; 
int      res          = WebRequest("GET","https://api.binance.com/api/v3/klines?symbol=BTCUSDT&interval=1m&limit=6","Content-Type:application/json",0,post,result,str);
   
if(res != 200)
{
      Print(res + "," + GetLastError());
} else {
      Print ("Server data:", result[1]);
      Print ("Server response:", CharArrayToString(result));	
}       

When I print out "Server response", I can see the array with data inside are retrieved successfully. But when I tried to retrieve one of the array element with "result[1]", it prints out "91"? Not sure what went wrong.

 
I am telling you a trick of the profs: place the cursor on WebRequest and press F1 - you'll find the direct HowTo of this function with an example to get the content ready to be copied ... ;)
 
Carl Schreiber #:
I am telling you a trick of the profs: place the cursor on WebRequest and press F1 - you'll find the direct HowTo of this function with an example to get the content ready to be copied ... ;)
I already read up the documentation, but there is no example related to this question.
 
vicknick #: I already read up the documentation, but there is no example related to this question.

JSON data is simply text. There is no binary arrays in it. The text needs to be parsed and converted into structured binary data.

 

As Fernando said , you will need a json library . (i think there is one built in i'm attaching one anyway)

Then you will look up how your data provider serves the data and format your extraction accordingly 

So if the data vendor has this format , for example : 

 

you will adapt your extraction like this 

  CJAVal loader;
  loader.Deserialize(CharArrayToString(result),CP_UTF8);  
  //# results 
  int venues_found=(int)StringToInteger(loader["results"].ToStr());
  //loop 
  for(int s=0;s<venues_found;s++)
  { 
  string _venue_id=loader["response"][s]["id"].ToStr();
  string _venue_name=loader["response"][s]["name"].ToStr();
  string _venue_address=loader["response"][s]["address"].ToStr();
  string _venue_city=loader["response"][s]["city"].ToStr();
  string _venue_capacity=loader["response"][s]["capacity"].ToStr();
  string _venue_surface=loader["response"][s]["surface"].ToStr();
  string _venue_image=loader["response"][s]["image"].ToStr();
  }
Files:
Reason: