Question: I am trying to integrate google cloud speech API in my demo app.
What I am getting as result is below :

```
    {
    results {
      alternatives {
        transcript: "hello"
      }
      stability: 0.01
    }
}

```

Code to get response : 

```
[[SpeechRecognitionService sharedInstance] streamAudioData:self.audioData
                                                withCompletion:^(StreamingRecognizeResponse *response, NSError *error) {
                                                  if (error) {
                                                    NSLog(@"ERROR: %@", error);
                                                    _textView.text = [error localizedDescription];
                                                    [self stopAudio:nil];
                                                  } else if (response) {
                                                    BOOL finished = NO;
                                                    //NSLog(@"RESPONSE: %@", response.resultsArray);
                                                    for (StreamingRecognitionResult *result in response.resultsArray) {
                                                        NSLog(@"result : %@",result);
                                                        //_textView.text = result.alternatives.transcript;
                                                      if (result.isFinal) {
                                                        finished = YES;
                                                      }
                                                    }

                                                    if (finished) {
                                                      [self stopAudio:nil];
                                                    }
                                                  }
                                                }
     ];

```

My problem is, the response i am getting is not a proper JSON then how do i get the value of key `transcript` ? Any help would be appreciated. Thanks.

Answer: 
I doubt it's "arbitrary", rather it's most likely `npos` that is returned.

And it's easy to see why if you read e.g. [this `find_last_of` reference](http://en.cppreference.com/w/cpp/string/basic_string/find_last_of), where it says that the `pos` argument is

> 
> position at which the search is to finish 
> 
> 
> 

So when you pass `0` as the position, you tell `find_last_of` to stop searching at the first character instead of the last.

The simple solution is to not pass the (optional) position argument at all:

```
str.find_last_of('=')

```

And of course to have a check for `npos` being returned.
Second argument is wrong, try:

```
#include <string>
#include <iostream>
int main() 
{
    std::string str = "page id = 0 file = \"simsun.png\" chars count = 97";
    size_t index = str.find_last_of('=');
    std::cout << index << std::endl;
    return 0;
}

```