So I have simple JSON string that I'm iterating through with a for loop (don't ask why I'm not using a json parser).
In this loop I want to kick out {
, }
and ''
(the misplaced
}
is just there for debugging reasons)
Here is the code:
std::string str("{'pi': 3.141, 'happy': }true }");
for (int i = 0; i < str.length(); i++)
{
char temp = str[i];
if (temp == '{' || temp == '}' || temp == ' ' )
str.erase(i, 1);
}
Not very complicated and it basically works just fine but for some reason the }
gets skipped. It just iterates through the string like it wouldn't even be there. Can anyone reproduce this behavior? I'm totally out of ideas what could be wrong here.
EDIT: Ok, I can see how this might be a duplicate of the other post but to be fair it's hard to stumble upon a post about vectors when having problems with a string