If in a state of “readiness” checks if the current character is the expected one. If so increment or change the state.
// For states where state increments by one if the expected character is the // current one in the stream. BOOL Expect(char c) { char ExpectArray[11] = ""; //X is don't care if (c == ExpectArray[parseState]) { IncrementState(); return true; } //A 'fix' to facilitate parsing of JSON strings that aren't arrays: else if (('{' == c) && (startOfArray == parseState)) { //Permit parsing of records only parseState = startOfName; } else { //Expectation wasn't satified so error output.print(F("Expected: ")); output.println(ExpectArray[parseState]); output.print(F("Got: ")); output.println(c); parseState = error; output.print(F("Expect Next Err: ")); output.println(parseState); ErrNo = 10; return false; } return true; }