Unable to convert String to Double with StrToDouble

 
char     post[], result[];
string   str;
int      res          = WebRequest("GET","https://api.binance.com/api/v3/klines?symbol=BTCUSDT&interval=1m&limit=1","Content-Type:application/json",0,post,result,str);
  

string stringData = CharArrayToString(result);   
string sep=",";                
ushort u_sep;                  
string processedResult[];        
u_sep = StringGetCharacter(sep,0);
int k = StringSplit(stringData,u_sep,processedResult);

if(k > 0)
{
     for(int i=0;i<k;i++)
       {
           PrintFormat("result[%d]=%s",i,processedResult[i]); //This is able to print out all data in string
       }
}
Print(StrToDouble(processedResult[2])); //This gives only zero?

I was able to fetch data and seperate them into array of string. But when I tried to get a string element that is numeric and convert to double, it only prints out zero?  

 
vicknick:I was able to fetch data and seperate them into array of string. But when I tried to get a string element that is numeric and convert to double, it only prints out zero?  

You will have to supply an example of the data being parsed, otherwise we have no idea if you are parsing it correctly or not.

You should also show your logged output from your code.

 
  1. StrToDouble is deprecated. Use StringToDouble.

  2. Your code
    string sep=",";                
    ushort u_sep;                  
    u_sep = StringGetCharacter(sep,0);
    Simplified
    ushort u_sep = ',';
 
vicknick:

I was able to fetch data and seperate them into array of string. But when I tried to get a string element that is numeric and convert to double, it only prints out zero?  

You actually need to remove the double quotes from the processed results array strings 

like so :

void get(){
char     post[], result[];
string   str;
int      res          = WebRequest("GET","https://api.binance.com/api/v3/klines?symbol=BTCUSDT&amp;interval=1m&limit=1","Content-Type:application/json",0,post,result,str);
  

string stringData = CharArrayToString(result);   
string sep=",";                
ushort u_sep;                  
string processedResult[];        
u_sep = StringGetCharacter(sep,0);
int k = StringSplit(stringData,u_sep,processedResult);

if(k > 0)
{
     for(int i=0;i<k;i++)
       {
           PrintFormat("result[%d]=%s",i,processedResult[i]); //This is able to print out all data in string
       StringReplace(processedResult[i],"\"","");
       }
}
Print(StrToDouble(processedResult[2])); //This gives only zero?
}

To avoid log confusion i print logs within brackets so i know everything in the brackets is the response .The double quotes kinda tricked you here 

(i also got error 12002 sometimes i assume you have adressed it)

Cheers :)