Help removing [" and "] from my vPin HTTP GET

I’m using the ESP8266_ReadPin example and it works well. The serial monitor shows my data formatted ["75"]. However I’d like to get the data without the brackets and quotes, so just 75 (end goal being to use this data as an integer (or other) variable).

I know this is not a Blynk thing, but probably C (?) or just basic HTTP stuff. Can anyone share an example if they’ve successfully done this or point me in the right direction?

Thank you!

Maybe use isdigit() in the while (client.available()) loop, if true an integer will be the value -‘0’ and you will probably need to count through the loop to see how many digits are in the integer and multiply the left most digit by 10 for 2 digits, 100 for 3 digits.

Post your code if you get something working.

Thank you for the recommendation @Costas. I’ll give it a whirl today and post how it turns out!

You can hack the string, something like this:

String data = "[75]";
data.remove(0,1); //remove first character.
data.remove(data.length()-1); //remove the last character

After that calling .toInt() on a String will give you the number. See here for some more details:

I’ll play with this as well… didn’t even think about manipulating the string for some reason!

Well… success! (below a modification of this Blynk example):

    Serial.print("Read value: ");
    body.remove(0,2);  //  Starting at index 0, remove 2 characters.
    body.remove(body.length() - 2);  // Starting at 2 characters from the end of the string, remove everything after.
    int tempF = body.toInt();  // Convert string to int.
    Serial.println(tempF + 1);  // Confirm toInt() really worked!

I have a feeling this is a tad less graceful than Costa’s idea… but I’m going to try that next!